Add balance command for users to check their balance
This commit is contained in:
28
commands/balance.js
Normal file
28
commands/balance.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "balance");
|
||||
|
||||
const { checkBalance } = require("../controllers/accountController");
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('balance')
|
||||
.setDescription('Check your balance of AI tokens'),
|
||||
example: "balance",
|
||||
isPrivileged: false,
|
||||
requiresTokens: false,
|
||||
defaultTokenUsage: 0,
|
||||
deferInitialReply: false,
|
||||
async execute(interaction) {
|
||||
try{
|
||||
checkBalance(interaction.member.id, async (err, balance) => {
|
||||
if (err) throw err;
|
||||
|
||||
await interaction.reply({ content: `${interaction.member.user}, you have ${balance} tokens remaining`, ephemeral: true })
|
||||
})
|
||||
}catch(err){
|
||||
log.ERROR(err)
|
||||
await interaction.reply(`Sorry ${interaction.member.user}, something went wrong`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user