commit
This commit is contained in:
parent
8a23e86b12
commit
f6e5d49159
4 changed files with 57 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
import { SlashCommandBuilder, CommandInteraction, PermissionsBitField } from "discord.js";
|
||||
import { connectToDb, getguild, addGuild } from "../../libs/mysql.js"
|
||||
import { connectToDb, getGuild, addGuild } from "../../libs/mysql.js"
|
||||
import { errorEmbed, successEmbed } from "../../libs/discord.js";
|
||||
|
||||
export default {
|
||||
|
@ -11,7 +11,7 @@ export default {
|
|||
const guild_id: string = interaction.guildId ? interaction.guildId : "";
|
||||
const member = interaction.guild?.members.cache.get(interaction.user.id);
|
||||
|
||||
if (! member?.permissions.has(PermissionsBitField.Flags.ManageGuild)) {
|
||||
if (!member?.permissions.has(PermissionsBitField.Flags.ManageGuild)) {
|
||||
const embed = errorEmbed("You are not allowed to use that command.", interaction.client.user.displayAvatarURL());
|
||||
|
||||
return await interaction.reply({embeds: [embed]});
|
||||
|
@ -19,7 +19,7 @@ export default {
|
|||
|
||||
const connection = await connectToDb();
|
||||
|
||||
const guild: any[] = await getguild(connection, guild_id);
|
||||
const guild: any[] = await getGuild(connection, guild_id);
|
||||
|
||||
if (guild[0]) {
|
||||
const embed = await errorEmbed("Your server is already registered.", interaction.client.user.displayAvatarURL());
|
||||
|
|
39
src/commands/guilds/setAdminRole.ts
Normal file
39
src/commands/guilds/setAdminRole.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import { SlashCommandBuilder, ChatInputCommandInteraction, PermissionsBitField } from "discord.js";
|
||||
import { connectToDb, getGuild, setAdminRole } from "../../libs/mysql.js"
|
||||
import { errorEmbed, successEmbed } from "../../libs/discord.js";
|
||||
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("setadminrole")
|
||||
.setDescription("Set the admin role for the bot")
|
||||
.addRoleOption(option => option.setName("role").setDescription("The role to be admin.").setRequired(true)),
|
||||
async execute(interaction: ChatInputCommandInteraction) {
|
||||
const guild_id: string = interaction.guildId ? interaction.guildId : "";
|
||||
const member = interaction.guild?.members.cache.get(interaction.user.id);
|
||||
|
||||
if (!member?.permissions.has(PermissionsBitField.Flags.ManageGuild)) {
|
||||
const embed = errorEmbed("You are not allowed to use that command.", interaction.client.user.displayAvatarURL());
|
||||
|
||||
return await interaction.reply({embeds: [embed]});
|
||||
}
|
||||
|
||||
const connection = await connectToDb();
|
||||
|
||||
const guild: any[] = await getGuild(connection, guild_id);
|
||||
|
||||
if (!guild[0]) {
|
||||
const embed = errorEmbed("Your server must be registered to the bot, use /register to do so.", interaction.client.user.displayAvatarURL());
|
||||
|
||||
return interaction.reply({embeds: [embed]});
|
||||
}
|
||||
|
||||
const role_id: string | undefined = interaction.options.getRole("role")?.id
|
||||
|
||||
await setAdminRole(connection, guild_id, role_id ? role_id : "");
|
||||
|
||||
const embed = successEmbed("The bot admin role has been successfully changed.", interaction.client.user.displayAvatarURL())
|
||||
|
||||
interaction.reply({embeds: [embed]})
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue