Spaces:
Sleeping
Sleeping
Download src/commands/reset.js from Discord-Core-Bot/gateway-bot: direct link, hf CLI and curl.
- Browser
- Download file 1.76 kB
-
https://huggingface.co/spaces/Discord-Core-Bot/gateway-bot/resolve/main/src/commands/reset.js
- Command line
-
hf download hf://spaces/Discord-Core-Bot/gateway-bot/src/commands/reset.js
-
curl -L -o reset.js https://huggingface.co/spaces/Discord-Core-Bot/gateway-bot/resolve/main/src/commands/reset.js
1.76 kB
| 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 | |
| } | |
| } |