【问题标题】:Why doesn't my message.reply command not work?为什么我的 message.reply 命令不起作用?
【发布时间】:2020-02-21 13:44:47
【问题描述】:

我的机器人已连接到服务器,当我启动代码时它会在线,但我似乎无法弄清楚为什么 message.reply 命令不起作用

代码:

const Discord = require('discord.js');

const bot = new Discord.Client();

bot.on('Message', (message) => {

    if(message.content == 'ping') {

        message.reply('pong');
    }

});

我错过了什么吗?我正在使用 Visual Studio 代码进行编码

【问题讨论】:

  • 你试过小写的事件名称“message”吗?

标签: javascript node.js discord.js


【解决方案1】:

客户端的事件是区分大小写的,因此,“消息”和“消息”是完全不同的两个东西。

将第 5 行的“消息”替换为“消息”以修复您的代码。

const Discord = require('discord.js');
const bot = new Discord.Client();

bot.on('message', (message) => {
    if (message.content == 'ping') {
        message.reply('pong');
    }
});

【讨论】:

    猜你喜欢
    • 2022-01-04
    • 2015-04-29
    • 2020-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多