I was coding my bot this morning, it was working fine until I go to eat. When I came back the bot no longer wanted to boot up when I was executing my code. The weird thing is that I didn't changed anything in my code, I don't have any log message on console (usually success log when boot up properly) and It was working fine about 1h ago. I have tried reset bot's token but not working. I'm using Replit.com as Node.js project, here is the link.
const TOKEN = process.env['token']
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
function getLastWord(str) {
return (str.toLowerCase().match(/(\w+)\W*$/) || [])[1];
}
const activities = [
"test activity 1",
"test activity 2",
"test activity 3",
"test activity 4"
];
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`)
// run every 10 seconds
setInterval(() => {
// generate random number between 1 and list length.
const randomIndex = Math.floor(Math.random() * (activities.length - 1) + 1);
const newActivity = activities[randomIndex];
client.user.setActivity(newActivity,{ type: 'LISTENING' });
}, 10000);
});
client.on("message", msg => {
if (getLastWord(msg.content) === "quoi") {
msg.reply("feur");
}
if (client.users.cache.find(user => user.id === '422449611035115520') && msg.author.bot === false){
msg.reply("spotted");
}
})
client.login(TOKEN)
It worked again for 3h for no reasons and now it's not working anymore (again), sometimes the bot won't boot up I don't understand that's very random.