I started to learn about discord.js but now I'm facing this problem. I tried some intents but I couldn't fix it.
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);
There are missing closing parenthesis for client.on
hook, so your code should look like:
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.