刷新Slash命令后Discord.js机器人无法启动且无报错(Replit环境)
Discord.js机器人在Replit中无法启动(无报错)
我基于discord.js官网示例代码开发机器人,在Replit环境执行Slash命令刷新操作后,机器人无法启动且没有任何报错信息。即使移除所有Slash命令相关代码,机器人仍然无法正常启动。
以下是替换令牌/ID后的代码:
const { REST, Routes, Client, GatewayIntentBits } = require('discord.js'); const commands = [ { name: 'ping', description: 'Replies with Pong!', }, ]; const rest = new REST({ version: '10' }).setToken(process.env.BOT_TOKEN); (async () => { try { console.log('Started refreshing application (/) commands.'); await rest.put(Routes.applicationCommands(process.env.BOT_ID), { body: commands }); console.log('Successfully reloaded application (/) commands.'); } catch (error) { console.error(error); } })(); const client = new Client({ intents: [GatewayIntentBits.Guilds] }); client.on('ready', () => { console.log(`Logged in as ${client.user.tag}!`); }); client.on('interactionCreate', async interaction => { if (!interaction.isChatInputCommand()) return; if (interaction.commandName === 'ping') { await interaction.reply('Pong!'); } }); client.login(process.env.BOT_TOKEN);
控制台截图:
内容的提问来源于stack exchange,提问作者user15428862
相关产品推荐
相关产品推荐

