Spaces:
Sleeping
Sleeping
File size: 1,763 Bytes
9b7ecf4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | import { SlashCommandBuilder, PermissionFlagsBits, EmbedBuilder, MessageFlags } from 'discord.js'
import { initGuildConfig } from '../storage/cache.js'
export const data = new SlashCommandBuilder()
.setName('reset')
.setDescription('Reset all bot settings for this server to defaults')
.addSubcommand((sub) =>
sub
.setName('confirm')
.setDescription('Confirm the reset — this cannot be undone')
.addStringOption((opt) =>
opt
.setName('confirmation')
.setDescription('Type RESET to confirm')
.setRequired(true)
)
)
export async function execute(interaction) {
if (
!interaction.memberPermissions.has(PermissionFlagsBits.ManageGuild) ||
!interaction.memberPermissions.has(PermissionFlagsBits.Administrator)
) {
await interaction.reply({
content: 'You need both Manage Server and Administrator permissions to use this command.',
flags: MessageFlags.Ephemeral,
})
return
}
const sub = interaction.options.getSubcommand()
if (sub === 'confirm') {
const confirmation = interaction.options.getString('confirmation')
if (confirmation !== 'RESET') {
await interaction.reply({
content: 'You must type RESET exactly to confirm.',
flags: MessageFlags.Ephemeral,
})
return
}
await initGuildConfig(interaction.guild.id)
const embed = new EmbedBuilder()
.setColor(0xed4245)
.setTitle('Server Config Reset')
.setDescription(
'All settings have been reset to defaults.\nYou will need to run /setup channels again.'
)
await interaction.reply({ embeds: [embed], flags: MessageFlags.Ephemeral })
return
}
} |