[英]Discord bot is active, but isn't responding to discord inputs. Testing using a simple "ping" embed command
[英]Discord Bot not responding to ping command
我知道一些基本的 python 並且我決定嘗試制作 discord 機器人,但未能讓機器人響應命令。 我嘗試將“-ping”更改為“ping”並嘗試在我的 discord 服務器上輸入:
平平
但兩者都沒有做任何事情。 此外,
console.log('This does not run');
沒有出現在控制台中。
我不太確定我錯在哪里。 任何幫助,將不勝感激。 謝謝!
const {Client, Intents} = require('discord.js');
const {token} = require('./config.json');
const client = new Client({intents:[Intents.FLAGS.GUILDS]});
const prefix = '-';
client.once('ready', () => {
console.log('Bot works');
});
client.on('message', message => {
console.log('This does not run');
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ */);
const command = args.shift().toLowerCase();
if(command === '-ping'){
message.channel.send('pong');
}
});
client.login(token);
我認為您需要啟用GUILD_MESSAGES
意圖。 您可以將其添加到客戶端構造函數中的意圖列表中,如下所示:
const client = new Client({intents:[Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]});
非常感謝我有同樣的問題,但感謝您的建議解決了
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.