debug button/menu interactions

This commit is contained in:
SowinskiBraeden committed 2022-08-29 21:26:22 -07:00
1 parent eebda1c209
commit 70d3858baf
12 files changed
+844 -834

No files matched your search

+4 -65
View File
@@ -35,7 +35,7 @@ module.exports = {
if (!canUseCommand) return interaction.send('You don\'t have the permissions to use this command.');
const targetUserID = args[0].value.replace('<@!', '').replace('>', '');
const prompt = new EmbedBuilder()
.setTitle(`Are you sure you want to reset this user?`)
.setDescription('**Notice:** This will reset this users, cash, balance, and invnetory back to defaults.')
@@ -44,77 +44,16 @@ module.exports = {
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`yes-${interaction.member.user.id}`)
.setCustomId(`reset-yes-${targetUserID}-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`no-${interaction.member.user.id}`)
.setCustomId(`reset-no-${targetUserID}-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
if (queryString==`yes-${interaction.member.user.id}`) {
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle('Successfully reset user\'s data')
let inventory = await client.dbo.collection("inventories").findOne({"inventory.userID": interaction.member.user.id}).then(inventory => inventory);
let banking = await client.dbo.collection("banks").findOne({"account.userID": interaction.member.user.id}).then(banking => banking);
let inventoryReset = false;
let bankingReset = false;
if (!inventory) inventoryReset = true
else inventory = inventory.inventory
if (!banking) bankingReset = true
else banking = banking.banking
if (inventoryReset && bankingReset) return ButtonInteraction.update({ embeds: [successEmbed], components: [] });
if (!inventoryReset) {
const success = addInventory(inventory.guilds, GuildDB.serverID, targetUserID, client);
if (!success) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return ButtonInteraction.update({ embeds: [embed], components: [] });
}
}
if (!bankingReset) {
const success = addBank(banking.guilds, GuildDB.serverID, targetUserID, client);
if (!success) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return ButtonInteraction.update({ embeds: [embed], components: [] });
}
}
return ButtonInteraction.update({ embeds: [successEmbed], components: [] });
} else if (queryString==`no-${interaction.member.user.id}`) {
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`The User was not reset`);
return ButtonInteraction.update({ embeds: [successEmbed], components: [] });
}
});
return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
},
},