My discord.js version is v13, and it's not sending a message, nor is it giving an error in the console so that I can try to figure out what is wrong with it.
The code itself is over 4000 lines of code, so I tried putting it in a separate script to only test one function (which is the ping function), yet still nothing.
If you ask, this the async
is only apart of another function in the main script where I use await
a lot.
const Discord = require('discord.js');
const client = new Discord.Client({ intents: [ 'DIRECT_MESSAGES', 'GUILD_MESSAGES' ] });
const config = require("./config.json");
client.on("ready", () => {
console.log(`Main script ready! Currently in ${client.guilds.size} servers!`);
client.user.setActivity("Using a test script");
});
client.on('messageCreate', async message => {
if(message.author.bot) return;
if(message.content.indexOf(config.prefix) !== 0) return;
const args = message.content.slice(config.prefix.length).trim().split(/ /g);
const command = args.shift().toLowerCase()
if (message.channel.type == "dm") return;
if(command === "ping") {
const m = await message.channel.send("Loading...")
m.edit(`Pong! ${m.createdTimestamp - message.createdTimestamp}ms. API ${Math.round(client.ping)}ms`)
}
});
client.login(config.token);
CodePudding user response:
You are missing Intents.FLAGS.GUILDS.
Change:
const client = new Discord.Client({ intents: [ 'DIRECT_MESSAGES', 'GUILD_MESSAGES' ] });
to
const client = new Discord.Client({ intents: [ 'GUILDS', 'DIRECT_MESSAGES', 'GUILD_MESSAGES' ] });