inventory clear command/fix settings prompts?

This commit is contained in:
SowinskiBraeden committed 2022-08-01 20:35:52 -07:00
1 parent faea3166e1
commit 766c8171f0
2 files changed
+101 -20

No files matched your search

+60 -1
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
const Inventory = require('../structures/inventory');
const action = ['ditch', 'drop', 'forget', 'throw out', 'leave', 'set down', 'let go of'];
@@ -78,6 +78,12 @@ module.exports = {
}
],
},
{
name: "clear",
description: "clear your inventory",
value: "clear",
type: 1,
}
],
/**
*
@@ -306,6 +312,59 @@ module.exports = {
.setColor('GREEN');
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].name == 'clear') {
const prompt = new MessageEmbed()
.setTitle(`Are you sure you want to clear your inventory?`)
.setDescription('**Note:** This will not affect your wallet.')
.setColor(client.config.EmbedColor)
const opt = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle("SUCCESS")
)
interaction.send({ embeds: [prompt], components: [opt] });
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",
ephemeral: true
})
}
let action = ''
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'cleared';
const tempWallet = inventory.items[0];
client.dbo.collection("inventories").updateOne({"inventory.userID":inventory.userID},{$set:{"inventory.items": [tempWallet]}},function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully ${action} your inventory.`)
return ButtonInteraction.update({ embeds: [successEmbed], components: [] });
});
return;
}
},
},