Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • maurice-hoeppner/LUH-Informatik-Bot
1 result
Show changes
Commits on Source (2)
const {SlashCommandBuilder} = require('@discordjs/builders');
const locale = require('../util/locale');
module.exports = (loc) => {
const commandLocale = locale.get(loc).slashCommands.add_role_menu;
return new SlashCommandBuilder()
.setName('rolemenu')
.setDescription('') // TODO
.addSubcommand(cmd => {
cmd.setName('create')
.addStringOption(opt =>
opt.setName('message')
.setRequired(true)
)
for(let i = 1; i <= 16; i++) {
cmd.addRoleOption(opt =>
opt.setName(`role${i}`))
}
return cmd;
})
}
\ No newline at end of file
......@@ -49,7 +49,7 @@ async function addRoleMenu(interaction) {
emoji: '2️⃣'
}
])
.setMaxValues(3)
.setMaxValues(2)
.setMinValues(0)
);
const msg = await channel.send({content: messageContent, components: [row1]});
......@@ -320,10 +320,7 @@ const slashCommandHandler = async (interaction, client) => {
const selectMenuHandler = async (interaction, client) => {
if (interaction.customId === 'selectRole') {
const config = await ServerConfig.findOne({guildID: interaction.guild.id.toString()});
let locale = 'en';
if (config != null) {
locale = config.locale;
}
const locale = config?.locale || 'en';
const functionLocale = locales.get(locale).components.roleMenu;
const guild = interaction.guild;
const channel = interaction.channel;
......@@ -334,7 +331,7 @@ const selectMenuHandler = async (interaction, client) => {
messageID: message.id
});
if (menu != null) {
if (interaction.values[0] === 'select_reset') {
if (interaction.values.includes('select_reset')) {
const roleIDs = menu.roles.map(role => role.roleID);
roleIDs.forEach(roleID => interaction.member.roles.remove(roleID));
await interaction.reply({content: functionLocale.interactionMessage.roleRemoved, ephemeral: true});
......@@ -349,8 +346,36 @@ const selectMenuHandler = async (interaction, client) => {
}
}
}
const newSlashCommandHandler = async (act, client) => {
}
const newSelectMenuHandler = async (act, client) => {
if(act.customId !== 'selectRole') return;
const config = await ServerConfig.findOne({guildID: act.guild.id.toString()});
const locale = config?.locale || 'en';
const functionLocale = locales.get(locale).components.roleMenu;
const menu = await RoleMenu.findOne({
guildID: act.guild.id,
channelID: act.channel.id,
messageID: act.message.id
});
if (menu) {
const roleIDs = menu.roles.map(role => role.roleID);
menu.roles.forEach(role => act.member.roles[act.values.includes[role.value] ? 'add' : 'remove'](role.id))
// roleIDs.forEach(roleID => interaction.member.roles.remove(roleID));
// act.member.roles.add(roleIDs[menu.roles.map(role => role.value).indexOf(act.values[0])]);
await act.reply({content: functionLocale.interactionMessage.roleAdded, ephemeral: true});
} else {
await act.reply({content: functionLocale.internalError, ephemeral: true});
}
}
module.exports = {
slashCommandHandler,
slashCommandHandler: slashCommandHandler,
//buttonHandler,
selectMenuHandler
}
\ No newline at end of file
selectMenuHandler: newSelectMenuHandler
}
......@@ -129,7 +129,7 @@
"permConfig": {
"replyAssign": "Role $$ROLE$$ has been aded to $$PERM$$ permission.",
"replyRevoke": "Role $$ROLE$$ has been removed from $$PERM$$ permission.",
"replyList": "List of Permissions:\n\nRole Menu: $$ROLEMENU$$\nLocale: $$LOCALE$$\nCourse Collection: $$COLLECTION$$\nManage member status of roles: $$MEMBERMANAGEMENT",
"replyList": "List of Permissions:\n\nRole Menu: $$ROLEMENU$$\nLocale: $$LOCALE$$\nCourse Collection: $$COLLECTION$$\nManage member status of roles: $$MEMBERMANAGEMENT$$",
"accessDenied": "Only administrators can access this command."
},
"roleMenu": {
......