#No error and bot not come online

1 messages · Page 1 of 1 (latest)

tired yoke
#

use client.on

next comet
#

Ok

next comet
tired yoke
#

show again the whole code

next comet
#

That is whole code

tired yoke
#

as I said before, use client.on

next comet
#
const { Client, Intents } = require('discord.js');
const token = process.env['TOKEN'];

const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

client.on('ready', () => {
client.user.setPresence({ activities: [{
  name: 'Oto in' + client.guilds.size + 'with' + client.users.size,
  type: 'PLAYING',
}], status: 'idle' });
console.log('Ready!');
});

client.login(token);
#

See

#

@tired yoke

tired yoke
#

does ready event gets fired at all? put a breakpoint at client.user.setPresence, or a console.log above it

next comet
#

Ok

tired yoke
#

this error should not be triggered by the code changes suggested by me. if you changed the code again, please show it

next comet
#

Again that old error

tired yoke
#

do a console.log(process.env['TOKEN'])

next comet
#
const { Client, Intents } = require('discord.js');
const config = process.env;

const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

client.on('ready', () => {
  
client.user.setPresence({ activities: [{
  name: 'Oto in' + client.guilds.size + 'with' + client.users.size,
  type: 'PLAYING',
}], status: 'idle' });
  
console.log('Ready!');
});

client.login(config.TOKEN);
tired yoke
#

follow at least one of my steps:

does ready event gets fired at all? put a breakpoint at client.user.setPresence, or a console.log above it

do a console.log(config.TOKEN)

next comet
tired yoke
#

then that's the problem. you're not logging in using a valid token

next comet
#

no token is correct

tired yoke
#

likely you're not setting the env variable TOKEN

next comet
#

Let me show you full code

#
const { Client, Intents } = require('discord.js');
const config = process.env;

const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

client.on('ready', () => {
console.log('Ready!');
client.user.setPresence({ activities: [{
  name: 'Oto in' + client.guilds.size + 'with' + client.users.size,
  type: 'PLAYING',
}], status: 'idle' });
});
 console.log(process.env['TOKEN'])

client.login(config.TOKEN);

const express = require('express');
const app = express();
const port = 3000;
app.use(express.static(__dirname));
app.listen(port);
tired yoke
#

if the line with console.log(process.env['TOKEN']) doesn't show anything, then your env variable TOKEN is empty

#

since it is empty, it is considered invalid

next comet
#

Token is logged in console

#

Is any error in intents

tired yoke
next comet
#

That's time it not logged

#

It looged after 5 sec

#

Is it possible that error is in intents

tired yoke
#

you are giving vague information, making the helping process harder

next comet
#

Sorry

tired yoke
tired yoke
next comet
#

One line is logging token

#

Only ex: Owjjsjsuwisoso

#

Like this

next comet
tired yoke
next comet
#

No

#

I am not telling you token it is example

tired yoke
#

ah, ok. you have to know that the format of the token is incorrect, if it really looks similar to that

#

do you still get the invalid token error?

next comet
#

No it not looks like that

#

No

next comet
#

No error coming

tired yoke
#

and bot is not online? (it can take some secs for the bot to come online)

tired yoke
#

i guess not even console.log('Ready!'); shows anything

next comet
#

Yes it is also not showing

tired yoke
#

temporarily delete all express stuff (5 lines), and run the code again

next comet
#

Ok

#
const { Client, Intents } = require('discord.js');
const config = process.env;

const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

client.on('ready', () => {
console.log('Ready!');
client.user.setPresence({ activities: [{
  name: 'Oto in' + client.guilds.size + 'with' + client.users.size,
  type: 'PLAYING',
}], status: 'idle' });
});

client.login(config.TOKEN);

///const express = require('express');
///const app = express();
///const port = 3000;
///app.use(express.static(__dirname));
///app.listen(port);
#

Done

#

Still not working

#

@tired yoke