#Client.user is null

1 messages ยท Page 1 of 1 (latest)

ornate coyote
#

here we go

#

a min

solar stirrup
#

๐Ÿ‘

ornate coyote
#

trying a other option

solar stirrup
#

"another" but cool ๐Ÿ‘

ornate coyote
#

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)
solar stirrup
#

"too" ๐Ÿ˜‰

#

Use a JS code block

#

Use Code blocks, it makes your code...

function codeBlock() {
  return '...Easier to Read';
}

```js
<code>
```
Note the 'js'

ornate coyote
#

oo thats nice

solar stirrup
#

IKR

#

So remind me of the issue, and which client is having it?

ornate coyote
#

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.

solar stirrup
#

So whst does GetClient do?

ornate coyote
#

1 time login

#

and get is just to get it for the api and bot

#

without making 2

solar stirrup
#

And the definition of client in that context?

ornate coyote
#

logging in 2

solar stirrup
#

Oh I see now

solar stirrup
#

You gave both in 1 code block, I'm with you

ornate coyote
#

yeah o sorry

#

didnt i add comment right

#

o yeah sorry

#

they are not so clear xd

solar stirrup
#

Ah...perhaps the client is not ready at that point...no, it's just a class so that shouldn't matter ๐Ÿค”

ornate coyote
#

i litterly dont understand

solar stirrup
#

Ah ha!

#

I see it I believe

ornate coyote
#

its the method that I have been using for over half a year

#

and if then also the client.user = null

solar stirrup
#

GetClient is async

ornate coyote
#

then my bot would crash xd

solar stirrup
#

Drop the async

ornate coyote
#

Still null

#

i added the async to test xd

solar stirrup
#

Ok console.log client before the return

#

And after the require

ornate coyote
#

client.js *

solar stirrup
#

Yea

ornate coyote
#

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

solar stirrup
#

Why do I feel like you are mssing some Bot Scopes ๐Ÿค”

#

You been through the setup guide?

ornate coyote
#

which you refer to?

solar stirrup
#

Just the DJS guide for bots

ornate coyote
#

im using this already for half a year.
Never had any problems
So they need to have changed something

solar stirrup
#

There's a step regarding the Dev Portal

ornate coyote
#

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.

solar stirrup
#

Not sure atm

#

G2G for like 10mins but shall be back

ornate coyote
#

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

solar stirrup
#

Humm?

ornate coyote
#

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

solar stirrup
#

Haha, GG

ornate coyote
#

you got any idea?

solar stirrup
#

Not atm, need to go for a few

ornate coyote
#

okie np man

#

ty for helping me