update/view bot admin roles via config

This commit is contained in:
SowinskiBraeden committed 2024-11-10 18:35:48 -08:00
1 parent 5e0a45554f
commit 5859c07571
3 files changed
+58 -18

No files matched your search

+56 -16
View File
@@ -105,7 +105,7 @@ module.exports = {
name: "view", name: "view",
description: "View configured allowed channels", description: "View configured allowed channels",
value: "view", value: "view",
type: CommandOptionTypes.SubCommand, type: CommandOptions.SubCommand,
} }
] ]
}, },
@@ -166,25 +166,40 @@ module.exports = {
name: "bot_admin_role", name: "bot_admin_role",
description: "Set/remove bot admin role", description: "Set/remove bot admin role",
value: "bot_admin_role", value: "bot_admin_role",
type: CommandOptions.SubCommand, type: CommandOptions.SubCommandGroup,
options: [ options: [
{ {
name: "action", name: "add",
description: "Set or remove a role to be a bot administrator", description: "Configure role to be bot admin",
value: "action", value: "add",
type: CommandOptions.String, type: CommandOptions.SubCommand,
choices: [ options: [{
{ name: 'add', value: 'add' }, { name: 'remove', value: 'remove' },
],
required: true,
},
{
name: "role", name: "role",
description: "Role to configure", description: "Role to confiure",
value: "role", value: "role",
type: CommandOptions.Role, type: CommandOptions.Role,
required: true, required: true,
}]
}, },
{
name: "remove",
description: "Remove configured role as bot admin",
value: "remove",
type: CommandOptions.SubCommand,
options: [{
name: "role",
description: "Role to remove",
value: "role",
type: CommandOptions.Role,
required: true,
}]
},
{
name: "view",
description: "View the configured bot admin roles",
value: "view",
type: CommandOptions.SubCommand,
}
] ]
}, },
{ {
@@ -511,8 +526,9 @@ module.exports = {
} }
case 'bot_admin_role': case 'bot_admin_role':
if (args[0].options[0].value == 'add') { const bot_admin_config = args[0].options[0].name;
const botAdminRoleId = args[0].options[1].value; const botAdminRoleId = ['add', 'remove'].includes(bot_admin_config) ? args[0].options[0].options[0].value : null;
if (bot_admin_config == 'add') {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$push: {"server.botAdminRoles": botAdminRoleId}}, (err, res) => { client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$push: {"server.botAdminRoles": botAdminRoleId}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err); if (err) return client.sendInternalError(interaction, err);
@@ -524,7 +540,7 @@ module.exports = {
return interaction.send({ embeds: [successSetBotAdminRoleEmbed] }); return interaction.send({ embeds: [successSetBotAdminRoleEmbed] });
} else if (args[0].options[0].value== 'remove') { } else if (bot_admin_config == 'remove') {
if (!GuildDB.botAdminRoles.includes(botAdminRoleId)) { if (!GuildDB.botAdminRoles.includes(botAdminRoleId)) {
const nonAdminRoleEmbed = new EmbedBuilder() const nonAdminRoleEmbed = new EmbedBuilder()
@@ -551,6 +567,30 @@ module.exports = {
) )
return interaction.send({ embeds: [promptRemoveAdminRole], components: [optRemoveAdminRole], flags: (1 << 6) }); return interaction.send({ embeds: [promptRemoveAdminRole], components: [optRemoveAdminRole], flags: (1 << 6) });
} else if (bot_admin_config == 'view') {
if (GuildDB.botAdminRoles.length == 0) {
const noBotAdminRoles = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setTitle('Admin Roles')
.setDescription('> There have been no configured admin roles');
return interaction.send({ embeds: [noBotAdminRoles] });
}
const botAdminRolesEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setTitle('Admin Roles')
let des = '';
for (let i = 0; i < GuildDB.botAdminRoles.length; i++) {
des += `\n> <@&${GuildDB.botAdminRoles[i]}>`;
}
botAdminRolesEmbed.setDescription(des);
return interaction.send({ embeds: [botAdminRolesEmbed] });
} }
case 'admin_role': case 'admin_role':
+1 -1
View File
@@ -24,7 +24,7 @@ module.exports = {
let noExcludes = new EmbedBuilder() let noExcludes = new EmbedBuilder()
.setColor(client.config.Colors.Default) .setColor(client.config.Colors.Default)
.setTitle('Excluded Roles') .setTitle('Excluded Roles')
.setDescription('> There have been no configured channels'); .setDescription('> There have been no excluded roles');
return interaction.send({ embeds: [noExcludes] }); return interaction.send({ embeds: [noExcludes] });
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "dayzr-bot", "name": "dayzr-bot",
"version": "13.3.8", "version": "13.3.9",
"description": "A General Purpose Discord Bot for DayZ Nitrado Servers.", "description": "A General Purpose Discord Bot for DayZ Nitrado Servers.",
"main": "index.js", "main": "index.js",
"nodemonConfig": { "nodemonConfig": {