#Client.user is null
1 messages ยท Page 1 of 1 (latest)
๐
trying a other option
"another" but cool ๐
haha
i type to fast
Here you go
CLIENT.JS
const botConfig = require("../botconfig.json");
const { GatewayIntentBits, Partials } = require("discord.js")
const discord = require("discord.js")
const client = new discord.Client({
intents:
[
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildVoiceStates
],
partials: [Partials.Message, Partials.Channel, Partials.Reaction, Partials.GuildMember, Partials.GuildScheduledEvent, Partials.User]
})
client.commands = new discord.Collection();
client.login("other token to try if its working.");
module.exports.GetClient = async () => {
return client
}
INDEX.JS
const ClientFile = require("../App/functions/client");
const apiClient = ClientFile.GetClient();
console.log(apiClient.user)
"too" ๐
Use a JS code block
Use Code blocks, it makes your code...
function codeBlock() {
return '...Easier to Read';
}
```js
<code>
```
Note the 'js'
oo thats nice
when I console.log(apiClient.user) user is null
but if I console.log(apiClient) the presense is just online
so its logged in and you can also see that in discord.
So whst does GetClient do?
module.exports.GetClient = async () => {
return client
}
1 time login
and get is just to get it for the api and bot
without making 2
And the definition of client in that context?
logging in 2
Oh I see now
wdym
You gave both in 1 code block, I'm with you
Ah...perhaps the client is not ready at that point...no, it's just a class so that shouldn't matter ๐ค
i litterly dont understand
its the method that I have been using for over half a year
and if then also the client.user = null
GetClient is async
then my bot would crash xd
Drop the async
in the client?
client.js *
Yea
yeah i did that
what you need?
presence: ClientPresence {
userId: null,
guild: null,
status: 'online',
activities: [],
clientStatus: null
},
user: null,
application: null,
readyTimestamp: null,
commands: Collection(0) [Map] {},
[Symbol(kCapture)]: true
application null
wtf
its litterly online
Why do I feel like you are mssing some Bot Scopes ๐ค
You been through the setup guide?
which you refer to?
Just the DJS guide for bots
im using this already for half a year.
Never had any problems
So they need to have changed something
There's a step regarding the Dev Portal
o yeah lemme check again xd
not really any scope
for adding it to the server its bot an application commands
but still they dont matter for the client.
okie
console.log(client)
client.login("secrettokenlmao");
console.log(client)
When i do this
only difference between the two
Before -> After
OMG
ofcourse
im so stupid
Humm?
i found it
it takes like 1/2 seconds before the client give the ready event
then it give all the properties a value
ยฏ_(ใ)_/ยฏ
lets build that in the client.js file
Haha, GG
you got any idea?
Not atm, need to go for a few