我的机器人在复制文本然后将其发送回时遇到问题

时间:2020-09-03 13:55:47

标签: javascript node.js discord discord.js

我使用discord.js,并且正在制作一个机器人,该机器人可以发回用户键入的文本,但是无论我怎么尝试都会遇到问题。

这是我尝试过的:

let s4 = (message.channel, message.content);

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) {
        messege.channel.send(s1 + s4);
    }
});

1 个答案:

答案 0 :(得分:1)

您的问题似乎在其中

const command = args.shift().toLowerCase();

if (command) {
    messege.channel.send(s1 + s4);
}

您正在将数组放入in语句中,而没有将其转换为布尔值的方法。您可能遇到的另一个问题是该命令是一个常量。我建议将其替换为

let command = args.shift().toLowerCase();
messege.channel.send(s1 + s4);

另外,阅读注释,就像您在定义消息对象之前引用了消息对象一样

以后,请将您收到的错误添加到您的问题中