I'm trying to log in to my discord bot but it only works using discord.js v12. I also have a config file where I stored my token so I could use config.token, but it shows invalid.
When I use v13 none works. Even when I use the actual token it shows invalid and when I use config.token it shows invalid too. Here is the code:
console.clear();
const Discord = require("discord.js");
const config = require("./Data/config.json");
const intents = new Discord.Intents(32767);
const client = new Discord.Client({ intents });
client.on("ready", () => console.log("Bot is online!"));
client.on("messageCreate", message => {
if(message.content == "hello") message.reply("Hello!");
});
client.login("token");
The bot also doesn't reply back too. This is my config file.
{
"token": "token",
"prefix": "!"
}
You are trying to log in using a string, to use the token variable from your config, use client.login(config.token), without quotes around it. This gets the config variable, then the token variable inside it, or config.token.
Your code would look something like this:
console.clear();
const Discord = require("discord.js");
const config = require("./Data/config.json");
const intents = new Discord.Intents(32767);
const client = new Discord.Client({ intents });
client.on("ready", () => console.log("Bot is online!"));
client.on("messageCreate", message => {
if(message.content == "hello") message.reply("Hello!");
});
client.login(config.token);