forked from Pogy-Bot/Pogy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
root
committed
Dec 5, 2024
1 parent
fc3758c
commit 603ad13
Showing
15 changed files
with
131 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
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("deposit") | ||
.setDescription("Deposit a number of money to the bank.") | ||
.addStringOption((option) => option.setName("amount").setDescription("The amount to deposit.").setRequired(true)), | ||
async execute(interaction) { | ||
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(`Creating profile.\nUse this command again.`) | ||
], | ||
ephemeral: true | ||
}); | ||
} else { | ||
const amount = interaction.options.getString("amount"); | ||
if (amount === "all") { | ||
await Profile.updateOne({ | ||
userID: interaction.user.id, guildId: interaction.guild.id | ||
}, { $inc: { wallet: -profile.wallet, bank: profile.wallet } }) | ||
await interaction.reply({ | ||
embeds: [ | ||
new MessageEmbed() | ||
.setColor("BLURPLE") | ||
.setDescription(`Deposited $${profile.wallet} to your bank.`) | ||
] | ||
}); | ||
} else if (amount > profile.wallet) { | ||
await interaction.reply({ | ||
embeds: [ | ||
new MessageEmbed() | ||
.setColor("BLURPLE") | ||
.setDescription(`You don't have enough money to deposit!`) | ||
], | ||
ephemeral: true | ||
}); | ||
} else { | ||
await Profile.updateOne({ | ||
userID: interaction.user.id, guildId: interaction.guild.id | ||
}, | ||
{ $inc: { wallet: -amount, bank: amount } }); | ||
await interaction.reply({ | ||
embeds: [ | ||
new MessageEmbed() | ||
.setColor("BLURPLE") | ||
.setDescription(`Deposited $${amount} to your bank.`) | ||
] | ||
}); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.