我对不和谐机器人相对较新,但我一生都无法弄清楚为什么我不断收到此错误 - 我试图用 message creat 替换 message,但它似乎根本不起作用.这是我的代码:
I am relatively new to discord bots but I cant for the life of me figure out why I keep getting this error - I have tried to replace message with message creat but it doesn't seem to work at all. Here is my code:
client.on('message', (message) => {
if(message.author.client) return;
if(message.channel.type !== 'text') return;
let prefix = '!';
let MessageArray = message.content.split(' ');
let cmd = MessageArray(0).slice(prefix.length)
let args = MessageArray.slice(1)
if(!message.content.startsWith(prefix)) return;
if(cmd == 'hello') {
message.channel.send({ messages: ['hello'] });
})
message 事件已重命名为 messageCreate.使用 message 仍然有效,但在您切换之前,您会收到弃用警告.
The message event has been renamed to messageCreate. Using message will still work, but you'll receive a deprecation warning until you switch over.
client.on("messageCreate", (message) => {
if (message.author.client) return;
if (message.channel.type !== "text") return;
let prefix = "!";
let MessageArray = message.content.split(" ");
let cmd = MessageArray(0).slice(prefix.length);
let args = MessageArray.slice(1);
if (!message.content.startsWith(prefix)) return;
if (cmd == "hello") {
message.channel.send({ messages: ["hello"] });
}
});
这篇关于DeprecationWarning:消息事件已被弃用.改用 messageCreate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
discord.js v12:我如何等待 DM 频道中的消息?discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 频道中的消息?)
如何让我的机器人提及发出该机器人命令的人how to make my bot mention the person who gave that bot command(如何让我的机器人提及发出该机器人命令的人)
如何修复必须使用导入来加载 ES 模块 discord.jsHow to fix Must use import to load ES Module discord.js(如何修复必须使用导入来加载 ES 模块 discord.js)
如何列出来自特定服务器的所有成员?How to list all members from a specific server?(如何列出来自特定服务器的所有成员?)
Discord bot:修复“找不到 FFMPEG"Discord bot: Fix ‘FFMPEG not found’(Discord bot:修复“找不到 FFMPEG)
使用 discord.js 加入 discord 服务器时的欢迎消息Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服务器时的欢迎消息)