Discord机器人发送不需要的消息

时间:2020-08-03 09:49:59

标签: discord bots discord.js

我有一个警告脚本,其中您基本上会警告duh,它可以工作,但是每次发送不想要的消息时都会

What is sends

这是我的剧本

const db = require("quick.db")
execute(message, args, prefix){
    if(!message.mentions.users.first())
    {
        message.channel.send("Please specify a user to warn")
        return;
    }
    if(args[1]){
        if(args[1].startsWith("<")){
        message.channel.send("You can only warn one person at a time")
        return;
        }
    }
    if(!args[1]){
        message.channel.send("Please specify a reson for the warn")
        return;
    }
    let warned = message.guild.member(message.mentions.users.first())
    message.channel.send(`${message.mentions.users.first}` + "You have been `warned` for " + args.slice(1).join(' '))
    if(!db.get(`WCount_${message.guild.id}_${warned}`)){
    db.set(`WCount_${message.guild.id}_${warned}`, 1)
    }else if(db.get(`WCount_${message.guild.id}_${warned}`)){
        db.set(`WCount_${message.guild.id}_${warned}`,db.get(`WCount_${message.guild.id}_${warned}`) + 1 )
    }
    message.channel.send(`${message.mentions.users.first()}, You now have ${db.get(`WCount_${message.guild.id}_${warned}`)} warns!`)
}

我很确定这是一个错误,但是请确保我在这里问了它 感谢您的帮助

1 个答案:

答案 0 :(得分:1)

在编写message.mentions.users.first的下一行中,您将附加实际函数的代码而不是调用它:

message.channel.send(`${message.mentions.users.first}` + "You have been `warned` for " + args.slice(1).join(' '))

您需要在函数后添加括号以确保调用它:

message.channel.send(`${message.mentions.users.first()}` + "You have been `warned` for " + args.slice(1).join(' '))