if (subcommand === 'add') { if (guildConfiguration.suggestionChannelIds.includes(channel.id)) { await interaction.editReply(`${channel} is already a suggestion channel.`); return; }
guildConfiguration.suggestionChannelIds.push(channel.id); await guildConfiguration.save(); await interaction.editReply(`Successfully added ${channel} as a suggestion channel.`); return; }
if (subcommand === 'remove') { if (!guildConfiguration.suggestionChannelIds.includes(channel.id)) { await interaction.editReply(`${channel} is not a suggestion channel.`); return; }
guildConfiguration.suggestionChannelIds = guildConfiguration.suggestionChannelIds.filter( (id) => id !== channel.id );
await guildConfiguration.save(); await interaction.editReply(`Successfully removed ${channel} from suggestion channels.`); return; } } catch (error) { console.error('Error in config-suggestion command:', error); if (!interaction.replied) { await interaction.editReply('An error occurred while processing your command.'); } } }, options: { userPermissions: ['Administrator'] }, data: new SlashCommandBuilder() .setName('config-suggestion') .setDescription('Configure suggestion channels for this server.') .setDMPermission(false) .addSubcommand(subcommand => subcommand .setName('add') .setDescription('Add a suggestion channel') .addChannelOption(option => option`your text` .setName('channel') .setDescription('The channel to add for suggestions') .addChannelTypes(ChannelType.GuildText) .setRequired(true) ) ) .addSubcommand(subcommand => subcommand .setName('remove') .setDescription('Remove a suggestion channel') .addChannelOption(option => option .setName('channel') .setDescription('The channel to remove from suggestions') .addChannelTypes(ChannelType.GuildText) .setRequired(true) ) ), }; [/code] [b] register-command.js[/b] [code]const { testServer } = require('../../../config.json'); const areCommandsDifferent = require('../../utils/commandDifferent'); const getApplicationCommands = require('../../utils/getApplicationCommand'); const getLocalCommands = require('../../utils/getLocalCommand');
for (const localCommand of localCommands) { // Extract command data from localCommand.data (SlashCommandBuilder) const commandData = localCommand.data || localCommand;
По какой -то причине, когда я запускаю команду, это возвращение приложение не отвечало < /strong> по какой -то причине. Я проверил, и он успешно связан с MongoDB.let guildConfiguration = await GuildConfiguration.findOne({ guildId: interaction.guildId }); console.log('guildConfiguration '); [/code] , который не дал результата, хотя я пытался запустить команду.