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

+304 -22
View File
@@ -418,11 +418,11 @@ module.exports = {
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`allowedChannels-yes-${interaction.member.user.id}`)
.setCustomId(`RemoveAllowedChannels-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`allowedChannels-no-${interaction.member.user.id}`)
.setCustomId(`RemoveAllowedChannels-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
@@ -458,11 +458,11 @@ module.exports = {
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`actionChannel-yes-${interaction.member.user.id}`)
.setCustomId(`RemoveActionChannel-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`actionChannel-no-${interaction.member.user.id}`)
.setCustomId(`RemoveActionChannel-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
@@ -497,11 +497,11 @@ module.exports = {
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`yes-${interaction.member.user.id}`)
.setCustomId(`RemoveTweetChannel-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`no-${interaction.member.user.id}`)
.setCustomId(`RemoveTweetChannel-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
@@ -536,11 +536,11 @@ module.exports = {
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`advertsChannel-yes-${interaction.member.user.id}`)
.setCustomId(`RemoveAdvertsChannel-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`advertsChannel-no-${interaction.member.user.id}`)
.setCustomId(`RemoveAdvertsChannel-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
@@ -576,11 +576,11 @@ module.exports = {
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`dispatchChannel-yes-${interaction.member.user.id}`)
.setCustomId(`RemoveDispatcherChannel-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`dispatchChannel-no-${interaction.member.user.id}`)
.setCustomId(`RemoveDispatcherChannel-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
@@ -658,11 +658,11 @@ module.exports = {
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`incomeRole-yes-${interaction.member.user.id}`)
.setCustomId(`RemoveIncomeRole-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`incomeRole-no-${interaction.member.user.id}`)
.setCustomId(`RemoveIncomeRole-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
@@ -693,11 +693,11 @@ module.exports = {
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`commercialRole-yes-${interaction.member.user.id}`)
.setCustomId(`RemoveCommercialRole-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`commercialRole-no-${interaction.member.user.id}`)
.setCustomId(`RemoveCommercialRole-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
@@ -728,11 +728,11 @@ module.exports = {
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`officerRole-yes-${interaction.member.user.id}`)
.setCustomId(`RemoveOfficerRole-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`officerRole-no-${interaction.member.user.id}`)
.setCustomId(`RemoveOfficerRole-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
@@ -763,11 +763,11 @@ module.exports = {
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`dispatchRole-yes-${interaction.member.user.id}`)
.setCustomId(`RemoveDispatcherRole-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`dispatchRole-no-${interaction.member.user.id}`)
.setCustomId(`RemoveDispatcherRole-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
@@ -799,11 +799,11 @@ module.exports = {
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`botAdmin-yes-${interaction.member.user.id}`)
.setCustomId(`RemoveBotAdminRole-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`botAdmin-no-${interaction.member.user.id}`)
.setCustomId(`RemoveBotAdminRole-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
@@ -844,11 +844,11 @@ module.exports = {
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`settingsReset-yes-${interaction.member.user.id}`)
.setCustomId(`ResetSettings-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`settingsReset-no-${interaction.member.user.id}`)
.setCustomId(`ResetSettings-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
@@ -902,4 +902,286 @@ module.exports = {
}
},
},
Interactions: {
RemoveAllowedChannels: {
run: async (client, interaction, GuildDB) => {
if (!queryString.endsWith(interaction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = ''
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull:{"server.allowedChannels": channelid}}, function (err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return interactino.update({ embeds: [successEmbed], components: [] });
}
},
RemoveActionChannel: {
run: async (client, interaction, GuildDB) => {
if (!queryString.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = ''
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.actionChannel": null}},function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveTweetChannel: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = ''
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.tweetChannel": null}},function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveAdvertsChannel: {
run: async (client, interaction, GuildDB) => {
if (!interaction.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.advertsChannel": null}},function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveDispatcherChannel: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.dispatchChannel": null}},function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveIncomeRole: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull: {"server.incomeRoles": roleId}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> from income roles.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveCommercialRole: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.commercialRole": null}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as commercial role.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveOfficerRole: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='no') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.officerRole": null}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as officer role.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveDispatcherRole: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.dispatcherRole": null}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as dispatcher role.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveBotAdminRole: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.botAdmin": null}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as the bot admin role.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
ResetSettings: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'reset';
const defaultGuildConfig = {
serverID: GuildDB.serverID,
allowedChannels: [],
actionChannel: null,
tweetChannel: null,
advertsChannel: null,
dispatchChannel: null,
startingBalance: 1000.00,
incomeRoles: [],
botAdmin: null,
commercialRole: null,
officerRole: null,
dispatcherRole: null,
onlyOfficersSearch: false,
}
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server": defaultGuildConfig}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} guild configurations.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
}
}
}