我在编写机器人时清除了错误,缺少意图


const Discord = require("discord.js");
const client = new Discord.Client({ ws: { intents: new Discord.Intents(Discord.Intents.ALL) } });

这是一个需要所有意图的代码是错误的吗

client.once('ready', () => {
console.log('Coleria is online!');
});
const prefix = '*'

我能用这个前缀吗

client.on("message", message =>{
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(" ");
const command = args.shift().toLowerCase();
if(command === 'sa'){
messageCreate.channel.send('As kardeşim hoşgeldin.');
}
});
client.login("my token");

您不应该使用ws: { intents: new Discord.Intents(Discord.Intents.ALL)}

const client = new Discord.Client({
intents: [
Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_MESSAGES
]
});

您应该使用此代码,因为您的机器人程序正在尝试查找GUILDSGUILD_MESSAGES标志,这就是您所需要使用的全部内容。

最新更新