【发布时间】:2022-11-11 23:09:30
【问题描述】:
如何获取机器人状态(discord.js 14.6.0)?在底部,我添加了我的代码 - 请耐心等待,因为这是我的第一个 JS 项目。
`
const { REST, Routes } = require('discord.js');
const commands = [
{
name: 'ping',
description: 'Replies with Pong!',
},
];
const rest = new REST({ version: '10' }).setToken("MY-TOKEN");
(async () => {
try {
console.log('Started refreshing application (/) commands.');
await rest.put(Routes.applicationCommands("CLIENT-ID"), { body: commands });
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
const { Client, GatewayIntentBits } = require('discord.js');
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("MY-TOKEN");
`
我试图处理互联网上的所有内容,但没有任何效果。
【问题讨论】:
-
请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如它目前所写的那样,很难准确地说出你在问什么。
-
如何在我的机器人中添加机器人状态? (discord.js 14.6.0)
标签: javascript discord.js bots