Skip to content

Commit

Permalink
Big update
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel Wood committed Nov 14, 2024
1 parent 1fa134a commit db3eb71
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 0 deletions.
71 changes: 71 additions & 0 deletions src/slashCommands/economy/beg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageEmbed } = require("discord.js");
const Profile = require("../../database/models/economy/profile");
const { createProfile } = require("../../utils/utils");

module.exports = {
data: new SlashCommandBuilder()
.setName("beg")
.setDescription("Beg for money"),
async execute(interaction) {
const amount = Math.floor(Math.random() * 2000);
const profile = await Profile.findOne({ userID: interaction.user.id, guildId: interaction.guild.id });
if (!profile) {
await createProfile(interaction.user, interaction.guild);
await interaction.reply({
embeds: [
new MessageEmbed()
.setColor("BLURPLE")
.setDescription(`Creatiing profile.\nUse this command again to beg for money.`)
],
ephemeral: true
});
} else {
if (!profile.lastBeg) {
await Profile.updateOne(
{
userID: interaction.user.id,
guildId: interaction.guild.id
},
{ $set: { lastBeg: Date.now() } }
);
await Profile.updateOne({ userID: interaction.user.id, guildId: interaction.guild.id }, { $inc: { wallet: amount } });
await interaction.reply({
embeds: [
new MessageEmbed()
.setColor("BLURPLE")
.setTitle(`${interaction.user.username}'s Beg`)
.setDescription(`You have beggedd ($${amount}).\nCome back in 3 minutes to beg again.`)
]
});
} else if (Date.now() - profile.lastBeg > 180000) {
await Profile.updateOne({
userID: interaction.user.id, guildId: interaction.guild.id
}, { $set: { lastBeg: Date.now() } });
await Profile.updateOne({ userID: interaction.user.id, guildId: interaction.guild.id }, { $inc: { wallet: amount } });
await interaction.reply({
embeds: [
new MessageEmbed()
.setColor("BLURPLE")
.setTitle(`${interaction.user.username}'s Beg`)
.setDescription(`You begged for a total of $${amount}.`)
]
});
} else {
const lastBeg = new Date(profile.lastBeg);
const timeLeft = Math.round((lastBeg.getTime() + 180000 - Date.now()) / 1000);
const minutes = Math.floor(timeLeft / 60);
const seconds = timeLeft - minutes * 60;
await interaction.reply({
embeds: [
new MessageEmbed()
.setColor("BLURPLE")
.setTitle(`${interaction.user.username}'s Beg cooldown`)
.setDescription(`You have to wait ${minutes}m ${seconds}s before you can beg again!`)
],
ephemeral: true
});
}
}
}
};
73 changes: 73 additions & 0 deletions src/slashCommands/economy/daily.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageEmbed } = require("discord.js");
const Profile = require("../../database/models/economy/profile");
const { createProfile } = require("../../utils/utils");
const { execute } = require("./beg");

module.exports = {
data: new SlashCommandBuilder()
.setName("daily")
.setDescription("Collect daily earnings. 24hr cooldown."),
async execute(interaction) {
const profile = await Profile.findOne({ guildId: interaction.guild.id, userID: interaction.user.id });
if (!profile) {
await createProfile(interaction.user, interaction.guild);
await interaction.reply({
embeds: [
new MessageEmbed()
.setColor("BLURPLE")
.setDescription(`Creating profile.\nUse this command again to collect your daily earnings!`)
],
ephemeral: true
});
} else {
if (!profile.lastDaily) {
await Profile.updateOne(
{
userID: interaction.user.id, guildId: interaction.guild.id
},
{ $set: { lastDaily: Date.now() } }
);
await Profile.updateOne({ userID: interaction.user.id, guildId: interaction.guild.id })
await interaction.reply({
embeds: [
new MessageEmbed()
.setColor("BLURPLE")
.setTitle(`${interaction.user.username}'s Daily`)
.setDescription(`You have collected todays earnings ($50000).\nCome back tomorrow to collect more.`)
]
});
} else if (Date.now() - profile.lastDaily > 86400000) {
await Profile.updateOne(
{ userID: interaction.user.id, guildId: interaction.guild.id },
{ $set: { lastDaily: Date.now() } }
);
await Profile.updateOne({ userID: interaction.user.id, guildId: interaction.guild.id }, { $inc: { wallet: 50000 } });
await interaction.reply({
embeds: [
new MessageEmbed()
.setColor("BLURPLE")
.setTitle(`${interaction.user.username}'s Daily`)
.setDescription(`You have collected your daily earnings of $50000.`)
],
ephemeral: true
});
} else {
const lastDaily = new Date(profile.lastDaily);
const timeLeft = Math.round((lastDaily.getTime() + 86400000 - Date.now()) / 1000);
const hours = Math.floor(timeLeft / 3600);
const minutes = Math.floor((timeLeft - hours * 3600) / 60);
const seconds = timeLeft - hours * 3600 - minutes * 60;
await interaction.reply({
embeds: [
new MessageEmbed()
.setColor("BLURPLE")
.setTitle(`${interaction.user.username}'s Daily cooldown`)
.setDescription(`You have to wait ${hours}h ${minutes}m ${seconds}s before you can collect your daily earnings!`)
],
ephemeral: true
});
}
}
}
};

0 comments on commit db3eb71

Please sign in to comment.