silvanus/slash-commands/rolemenu.js

30 lines
1.5 KiB
JavaScript
Raw Normal View History

2023-02-17 13:37:10 +00:00
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
2023-02-12 21:00:04 +00:00
const dbfn = require('../modules/dbfn.js');
2023-02-12 16:46:06 +00:00
const fn = require('../modules/functions.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('rolemenu')
.setDescription('Send a self-assignable role selection menu')
.addRoleOption(o =>
o.setName('waterrole')
.setDescription('The role for water reminder pings')
.setRequired(true))
.addRoleOption(o =>
o.setName('fruitrole')
.setDescription('The role for fruit alert pings')
2023-02-17 13:35:06 +00:00
.setRequired(false))
.setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles),
2023-02-12 16:46:06 +00:00
async execute(interaction) {
await interaction.deferReply().catch(err => console.error(err));
2023-02-12 20:29:38 +00:00
if (interaction.client.guildInfos.has(interaction.guildId)) {
let guildInfo = interaction.client.guildInfos.get(interaction.guildId);
2023-02-19 19:13:03 +00:00
guildInfo.setRoles(interaction.options.getRole('waterrole'), interaction.options.getRole('fruitrole'));
2023-02-12 21:00:04 +00:00
await dbfn.setGuildInfo(guildInfo.queryBuilder("setRoles"));
await fn.collectionBuilders.guildInfos(interaction.client);
2023-02-12 20:29:38 +00:00
await interaction.editReply(fn.builders.embeds.treeRoleMenu(guildInfo)).catch(err => console.error(err));
} else {
await interaction.editReply(fn.builders.errorEmbed("No information is known about your server yet, please run /setup or /compare")).catch(err => console.error(err));
}
2023-02-12 16:46:06 +00:00
},
};