♻️ credits balance
This commit is contained in:
parent
512ef3d3c0
commit
d458f0e18f
1 changed files with 29 additions and 20 deletions
|
@ -16,36 +16,46 @@ import fetchUser from "@helpers/fetchUser";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return (
|
||||||
.setName("balance")
|
command
|
||||||
.setDescription("Check a user's balance.")
|
.setName("balance")
|
||||||
.addUserOption((option) =>
|
.setDescription("Check a user's balance.")
|
||||||
option
|
|
||||||
.setName("user")
|
// User
|
||||||
.setDescription("The user whose balance you want to check.")
|
.addUserOption((option) =>
|
||||||
.setRequired(false)
|
option
|
||||||
);
|
.setName("user")
|
||||||
|
.setDescription("The user whose balance you want to check.")
|
||||||
|
)
|
||||||
|
);
|
||||||
},
|
},
|
||||||
execute: async (interaction: CommandInteraction) => {
|
execute: async (interaction: CommandInteraction) => {
|
||||||
// Destructure
|
|
||||||
const { options, user, guild } = interaction;
|
const { options, user, guild } = interaction;
|
||||||
|
|
||||||
// User option
|
const discordUser = options?.getUser("user");
|
||||||
const optionUser = options?.getUser("user");
|
|
||||||
|
|
||||||
if (guild === null) return;
|
if (guild === null) {
|
||||||
|
return interaction?.editReply({
|
||||||
|
embeds: [
|
||||||
|
new MessageEmbed()
|
||||||
|
.setTitle("[:dollar:] Credits (Balance)")
|
||||||
|
.setDescription(`We can not find your guild!`)
|
||||||
|
.setTimestamp(new Date())
|
||||||
|
.setColor(errorColor)
|
||||||
|
.setFooter({ text: footerText, iconURL: footerIcon }),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Get credit object
|
const userObj = await fetchUser(discordUser || user, guild);
|
||||||
const userObj = await fetchUser(optionUser || user, guild);
|
|
||||||
|
|
||||||
// If userObj does not exist
|
|
||||||
if (userObj === null) {
|
if (userObj === null) {
|
||||||
return interaction?.editReply({
|
return interaction?.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new MessageEmbed()
|
new MessageEmbed()
|
||||||
.setTitle("[:dollar:] Credits (Balance)")
|
.setTitle("[:dollar:] Credits (Balance)")
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`We can not find ${optionUser || "you"} in our database!`
|
`We can not find ${discordUser || "you"} in our database!`
|
||||||
)
|
)
|
||||||
.setTimestamp(new Date())
|
.setTimestamp(new Date())
|
||||||
.setColor(errorColor)
|
.setColor(errorColor)
|
||||||
|
@ -54,7 +64,6 @@ export default {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// If userObj.credits does not exist
|
|
||||||
if (userObj.credits === null) {
|
if (userObj.credits === null) {
|
||||||
return interaction?.editReply({
|
return interaction?.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
|
@ -62,7 +71,7 @@ export default {
|
||||||
.setTitle("[:dollar:] Credits (Balance)")
|
.setTitle("[:dollar:] Credits (Balance)")
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`We can not find credits for ${
|
`We can not find credits for ${
|
||||||
optionUser || "you"
|
discordUser || "you"
|
||||||
} in our database!`
|
} in our database!`
|
||||||
)
|
)
|
||||||
.setTimestamp(new Date())
|
.setTimestamp(new Date())
|
||||||
|
@ -77,7 +86,7 @@ export default {
|
||||||
new MessageEmbed()
|
new MessageEmbed()
|
||||||
.setTitle("[:dollar:] Credits (Balance)")
|
.setTitle("[:dollar:] Credits (Balance)")
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`${optionUser || "You"} have ${pluralize(
|
`${discordUser || "You"} have ${pluralize(
|
||||||
userObj.credits,
|
userObj.credits,
|
||||||
"credit"
|
"credit"
|
||||||
)}.`
|
)}.`
|
||||||
|
|
Loading…
Add table
Reference in a new issue