So, I was making my Discord bot as usual, and just at a moment this problem started popping up without any reason at all. It says the problem is caused by the end of the line, which is where my token is. I have no idea what exactly is causing it. I even looked at the code from the official Discord docs, everything should be right. Maybe I made a typo or something, no idea. I even regenerated the token itself multiple times and checked if it was right but it doesn't seem to work.
const fs = require('fs');
const Discord = require('discord.js');
const Client = new Discord.Client();
const client = new Discord.Client();
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
const cooldowns = new Discord.Collection();
Client.on('ready', ()=>{
console.log("ready to go");
});
Client.on('message', message =>{
if (!message.content.startsWith("e!") || message.author.bot) return;
const args = message.content.slice("e!".length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (!client.commands.has(command)) return;
try {
client.commands.get(command).execute(message, args);
} catch (error) {
console.error(error);
message.channel.send('An error happened while trying to execute that command. Consult the owner of the bot for possible fixes.');
}
Client.on('guildMemberAdd', member => {
const channel = member.guild.channels.cache.find(ch => ch.name === 'general');
if (!channel) return;
channel.send(`Welcome to the server, ${member}`);
})
Client.login("My token");
