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

+41 -19
View File
@@ -1,4 +1,4 @@
const { MessageEmbed, Guild } = require('discord.js');
const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
module.exports = {
name: "settings",
@@ -211,21 +211,28 @@ module.exports = {
const opt = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`yes`)
.setCustomId(`yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`no`)
.setCustomId(`no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle("SUCCESS")
)
interaction.send({ embeds: [prompt], components: [opt] });
client.once("interactionCreate", ButtonInteraction => {
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') {
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull:{"server.allowedChannels": channelid}}, function (err, res) {
if (err) {
@@ -237,7 +244,7 @@ module.exports = {
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString=='no') action = 'kept';
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new MessageEmbed()
.setColor("GREEN")
@@ -284,21 +291,28 @@ module.exports = {
const opt = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`yes`)
.setCustomId(`yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`no`)
.setCustomId(`no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle("SUCCESS")
)
interaction.send({ embeds: [prompt], components: [opt] });
client.once("interactionCreate", ButtonInteraction => {
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') {
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{"server.actionChannel": null}},function(err, res) {
if (err) {
@@ -310,7 +324,7 @@ module.exports = {
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString=='no') action = 'kept';
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new MessageEmbed()
.setColor("GREEN")
@@ -357,21 +371,28 @@ module.exports = {
const opt = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`yes`)
.setCustomId(`yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`no`)
.setCustomId(`no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle("SUCCESS")
)
interaction.send({ embeds: [prompt], components: [opt] });
client.once("interactionCreate", ButtonInteraction => {
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') {
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{"server.tweetChannel": null}},function(err, res) {
if (err) {
@@ -383,7 +404,7 @@ module.exports = {
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString=='no') action = 'kept';
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new MessageEmbed()
.setColor("GREEN")
@@ -411,13 +432,14 @@ module.exports = {
.setDescription(`Successfully set $${args[0].options[0].value.toFixed(2)} as starting balance`);
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].name == 'set_income_role') {
if (args[0].options[1].value <= 0) {
let embed = new MessageEmbed()
.setDescriptions('**Error Notice:** Amount cannot be $0 or less than $0.')
.setColor("RED");
.setDescriptions('**Error Notice:** Amount cannot be $0 or less than $0.')
.setColor("RED");
return interaction.send({ embeds: [embed] });
return interaction.send({ embeds: [embed] });
}
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==args[0].options[0].value);