我见过很多这个问题,我觉得我试过很多建议,但我不能让它起作用。现在,我只是记录messageCreate事件,但它无法工作。我将非常感谢你的帮助。
这是我的密码:
如你所见,我试过几件事^^
const { GatewayIntentBits, Partials, Guilds, Events } = require('discord.js');
const Discord = require('discord.js');
const Client = new Discord.Client({
intents: [
/* GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.DirectMessageTyping,
GatewayIntentBits.MessageContent, */
'Guilds', 'GuildMessages', 'DirectMessages', 'MessageContent'
],
partials: [
/* Partials.Channel,
Partials.GuildMember,
Partials.Message,
Partials.MessageReaction,
Partials.User,
Partials.GuildMessages,
Discord.PartialGroupDMChannel */
"CHANNEL", "GUILD_MEMBER", "MESSAGES", "MESSAGE_REACTION", "USER", "DMCHANNEL"
]
});
Client.on('messageCreate', async message => {
console.log('messageCreate event');
};我尝试过不同的方法来实现正确的意图和部分,但我即将失去理智。
发布于 2022-11-24 19:27:12
您必须从djs idk导入客户端,如果另一件事情能够工作,但我这样做的方法是,并在messageCreate中将客户端更改为客户端。
const { Client, GatewayIntentBits, Partials, Guilds, Events } = require('discord.js');
const Discord = require('discord.js');
const myIntents = new IntentsBitField();
myIntents.add(GatewayIntentBits.GuildMembers,GatewayIntentBits.GuildMessages,GatewayGatewayIntentBits.DirectMessages,GatewayIntentBits.DirectMessageTyping,GatewayIntentBits.Guilds,GatewayIntentBits.MessageContent);
const client = new Discord.Client({ partials: [Partials.Message, Partials.Channel, Partials.MessageReaction, Partials.User,Partials.GuildMessages, Discord.PartialGroupDMChannel], intents: myIntents }); 发布于 2022-11-24 19:41:21
将其添加到您的主/bot.js中
const { Client, GatewayIntentBits } = require("discord.js");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers
GatewayIntentBits.DirectMessages,
GatewayIntentBits.DirectMessageTyping,
GatewayIntentBits.DirectMessageReactions]
});
module.exports = client;如果使用的是eventHandler,则创建"messageCreate.js“文件并粘贴此代码
const client = require("YOUR_MAIN_FILE_PATH");
client.on("messageCreate", async(message)=>{
//Your code
})一些有用的网站:
https://stackoverflow.com/questions/74564760
复制相似问题