map and move interaction handlers

This commit is contained in:
SowinskiBraeden committed 2022-10-14 10:13:56 -07:00
1 parent 8850d02211
commit 19f41b5f2a
9 files changed
+622 -584

No files matched your search

+69 -2
View File
@@ -45,11 +45,11 @@ module.exports = {
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`reset-yes-${targetUserID}-${interaction.member.user.id}`)
.setCustomId(`Reset-yes-${targetUserID}-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`reset-no-${targetUserID}-${interaction.member.user.id}`)
.setCustomId(`Reset-no-${targetUserID}-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
@@ -58,4 +58,71 @@ module.exports = {
},
},
Interactions: {
Reset: {
run: async (client, interaction, GuildDB) => {
const choice = interaction.customId.split('-')[1];
const targetUserID = interaction.customId.split('-')[2];
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
if (choice=='yes') {
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({"banking.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 interaction.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 interaction.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 interaction.update({ embeds: [embed], components: [] });
}
}
return interaction.update({ embeds: [successEmbed], components: [] });
} else if (choice=='no') {
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`The User was not reset`);
return interaction.update({ embeds: [successEmbed], components: [] });
}
}
}
}
}