started to add bye messages
This commit is contained in:
parent
294af9c6af
commit
f37f0d492a
9 changed files with 300 additions and 92 deletions
|
@ -1,5 +1,5 @@
|
|||
import { SlashCommandBuilder, ChatInputCommandInteraction, PermissionFlagsBits } from "npm:discord.js";
|
||||
import { connectToDb, getGuild, setFeature } from "../../libs/mysql.ts";
|
||||
import { connectToDb, getGuild, setFeature, addGuild } from "../../libs/mysql.ts";
|
||||
import { errorEmbed, successEmbed } from "../../libs/discord.ts";
|
||||
|
||||
export default {
|
||||
|
@ -16,6 +16,7 @@ export default {
|
|||
{name: "Goodbye message", value: "bye_message"},
|
||||
])),
|
||||
async execute(interaction: ChatInputCommandInteraction) {
|
||||
await interaction.deferReply()
|
||||
const connection = await connectToDb();
|
||||
|
||||
const guild_id = interaction.guild?.id ? interaction.guild?.id : ""
|
||||
|
@ -23,17 +24,15 @@ export default {
|
|||
const guild = 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]});
|
||||
await addGuild(connection, guild_id);
|
||||
}
|
||||
|
||||
const member = interaction.guild?.members.cache.get(interaction.user.id)
|
||||
|
||||
if (!member?.permissions.has(PermissionFlagsBits.Administrator) && !member?.roles.cache.has(guild[0].admin_role_id)) {
|
||||
if (!member?.permissions.has(PermissionFlagsBits.Administrator) && (guild[0].admin_role_id && !member?.roles.cache.has(guild[0]?.admin_role_id))) {
|
||||
const embed = errorEmbed("You are not allowed to use that command.", interaction.client.user.displayAvatarURL());
|
||||
|
||||
return await interaction.reply({embeds: [embed]});
|
||||
return await interaction.editReply({embeds: [embed]});
|
||||
}
|
||||
|
||||
const feature: string | null = interaction.options.getString("feature")
|
||||
|
@ -42,8 +41,8 @@ export default {
|
|||
|
||||
connection.end()
|
||||
|
||||
const embed = successEmbed("The feature has been successfully activated.", interaction.client.user.displayAvatarURL())
|
||||
const embed = successEmbed("The feature has been successfully enabled.", interaction.client.user.displayAvatarURL())
|
||||
|
||||
interaction.reply({embeds: [embed]})
|
||||
interaction.editReply({embeds: [embed]})
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue