#Unable to login to discord boy with client.login
72 messages · Page 1 of 1 (latest)
• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.
Provide your code as well please
const { Client, GatewayIntentBits, Partials, Collection } = require('discord.js');
const client = new Client({
allowedMentions: {
parse: ["roles", "users", "everyone"],
repliedUser: false,
},
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent
],
partials: [Partials.Channel, Partials.Message, Partials.User, Partials.GuildMember, Partials.Reaction]
});
// require('dotenv').config() // remove this line if you are using replit
require(`colors`)
const { slash, prefix } = require(`${process.cwd()}/functions/cmdErrorLogs.js`);
client.config = require(`${process.cwd()}/json/config.json`);;
client.embed = require(`${process.cwd()}/json/embed.json`);
client.emotes = require(`${process.cwd()}/json/emojis.json`);;
client.slash_err = slash;
client.msg_err = prefix;
client.prefix = client.config.SETTINGS.PREFIX;
client.slashCommands = new Collection();
client.categories = new Collection();
client.cooldowns = new Collection();
client.commands = new Collection();
client.buttons = new Collection();
client.aliases = new Collection();
client.events = new Collection();
module.exports = client;
[`extraEvents`, `server`, 'command', 'slashCommand', 'events', `antiCrash`].forEach((handler) => {
require(`./handlers/${handler}`)(client)
});
console.log(process.env.CLIENT_ID);
client.on('debug', console.log)
.on('warn', console.log)
client.once('ready', () => {
console.log('Ready!');
});
client.login(process.env.TOKEN).catch((error) => { console.log((error.message).bold.red) });
Index.js
Cheers. Any errors or just exiting?
i was told to put
client.on('debug', console.log)
.on('warn', console.log)
issue is bot not loading
Does that log something?
bot not coming online
and no ready events taking place
client.on ready
those ones
that's all on running bot
Let's start clean:
require('dotenv').config();
const { Client, GatewayIntentBits, Partials, Collection } = require('discord.js');
const client = new Client({
allowedMentions: {
parse: ["roles", "users", "everyone"],
repliedUser: false,
},
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent
],
partials: [Partials.Channel, Partials.Message, Partials.User, Partials.GuildMember, Partials.Reaction]
});
client.once('ready', () => {
console.log('Started');
});
client.login(process.env.TOKEN);
Comment out the other stuff
ok
1 Sec. Also include ur .env. Updating code ^
using replit
So you're unable to use dotenv?
yeah
but token loads without it
so no prob
What error?
try doing kill 1 in shell
done its gone reconnecting
and?
yep
🙂
Don't go back yet to the old code, hang on
ok
What's the reason you're using the following:
const { slash, prefix } = require(`${process.cwd()}/functions/cmdErrorLogs.js`);
client.config = require(`${process.cwd()}/json/config.json`);;
client.embed = require(`${process.cwd()}/json/embed.json`);
client.emotes = require(`${process.cwd()}/json/emojis.json`);;
client.slash_err = slash;
client.msg_err = prefix;
client.prefix = client.config.SETTINGS.PREFIX;
client.slashCommands = new Collection();
client.categories = new Collection();
client.cooldowns = new Collection();
client.commands = new Collection();
client.buttons = new Collection();
client.aliases = new Collection();
client.events = new Collection();
module.exports = client;
and could you tell me correct way to end when i turn off bot
CTRL + C in your command line?
its needed
Says whom?
in whole handler its used
never seen it before.
i tried and it worked
ahh its just for terminal output?
@heady topazdo i have to do something to close ticket?
but now it is
Looks like killing everything fixed it
yeah
yeah
I forgot how to close it, but I guess on the right top on the 3 dots and close post or something. Or archive idk
You got ratelimited. Replit isn‘t a reliable host for discord bots because you share a host with lots of others and you call the API too much from that one host that way. Get a VPS to not get ratelimited.