不和谐版11.4.2
I输入!在通道中打个招呼,但机器人不发送消息
if(command === "!a hello"){
const msg = await message.channel.send("Checking Command...")
msg.edit("hello");
}发布于 2020-05-13 17:43:20
首先,您需要定义‘命令’,但在您的示例中,您可以使用command更改msg.content === '!a hello'。您也不必定义'msg',尽管我认为您仍然可以这样做。
你可以这样做:
bot.on("message", msg => {
if (msg.content === "!a hello") {
msg.channel.send("Checking Command...").then(msg => {
msg.edit(`hello`);
});
}
});告诉我,如果你需要什么,或需要删除或添加一些东西。希望这会有所帮助:)
发布于 2020-05-14 00:16:15
我的猜测是,在代码中的某个地方,您已经将“命令”定义为这样的东西。
const args = message.content.split(/ +/g);
const command = args.shift().toLowerCase();导致这个问题的原因可能是它的这一部分:".split(/ +/g);"将在子字符串之间插入一个空格的所有东西分割成子字符串。那你现在怎么解决呢?要么使用命令"!a-hello“,要么不使用”命令“。
if (message.content === "!a hello") {
const msg = await message.channel.send("Checking Command...")
msg.edit("hello");
};https://stackoverflow.com/questions/61771531
复制相似问题