[英]The bot does not respond to the message
我开始了解 discord.js 但现在我正面临这个问题。 我尝试了一些意图,但我无法修复它。
const Discord = require("discord.js");
const client = new Discord.Client({ intents: 3276799 });
const config = require("./config.json");
client.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;
if(!message.content.startsWith(config.prefix)) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
const comando = args.shift().toLowerCase();
// comando ping
if(comando === "ping") {
const m = await message.channel.send("Ping?");
m.edit(`Pong! A Latência é ${m.createdTimestamp - message.createdTimestamp}ms. A Latencia da API é ${Math.round(client.ping)}ms`);
}
client.login(config.token);
client.on
挂钩缺少右括号,因此您的代码应如下所示:
const Discord = require("discord.js");
const client = new Discord.Client({ intents: 3276799 });
const config = require("./config.json");
client.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;
if(!message.content.startsWith(config.prefix)) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
const comando = args.shift().toLowerCase();
// comando ping
if(comando === "ping") {
const m = await message.channel.send("Ping?");
m.edit(`Pong! A Latência é ${m.createdTimestamp - message.createdTimestamp}ms. A Latencia da API é ${Math.round(client.ping)}ms`);
}
})
client.login(config.token);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.