Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On READY event return null for ClientUser property #2

Closed
TheLittlePolaris opened this issue Dec 14, 2019 · 5 comments
Closed

On READY event return null for ClientUser property #2

TheLittlePolaris opened this issue Dec 14, 2019 · 5 comments
Assignees
Labels
bug Something isn't working todo 🗒️

Comments

@TheLittlePolaris
Copy link

TheLittlePolaris commented Dec 14, 2019

Problem:

on_ready_user_null
image
When i try to use the "ready" event, the value for user (UserClient) is null and i cannot use any of the ClientUser instance or method.

Expectation:

We should be able to use it the way the native discord.js module do
bot.on('ready', () => { bot.user.setActivity(...) })

My workaround solution for now:

workaround_solution

Much appreciate if you can fix it in the near feature :)

@TheLittlePolaris TheLittlePolaris changed the title On events return null for ClientUser property On READY event return null for ClientUser property Dec 14, 2019
@owengombas owengombas added bug Something isn't working todo 🗒️ labels Dec 15, 2019
@owengombas owengombas self-assigned this Dec 15, 2019
@Fredi100
Copy link

Fredi100 commented Mar 5, 2020

Isn't onReady in your case a member of the class you decorated with @Discord.
Your own class does not inherit Client. If you want access to the properties of the discord client object, you need to use it this way:

@On('ready')
async onReady(client: Client){
    console.log(client.user);
    // Do stuff with user
}

@TheDevMinerTV
Copy link

image
Okay, so I have the same issue and for some reason @On('ready') gets called twice.

@TheLittlePolaris
Copy link
Author

TheLittlePolaris commented Mar 14, 2020

Isn't onReady in your case a member of the class you decorated with @Discord.
Your own class does not inherit Client. If you want access to the properties of the discord client object, you need to use it this way:

@On('ready')
async onReady(client: Client){
    console.log(client.user);
    // Do stuff with user
}

The function is inside a class decorated with @Discord, do i still need to pass in the parameter for Client ?

@Fredi100
Copy link

Yes. @On injects the client object as the last parameter of the function which is why you have to include it. Take a quick look at the Readme

@owengombas
Copy link
Owner

Yes you have to use the client parameter on the event function :)

Thank's @Fredi100 for the support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working todo 🗒️
Projects
None yet
Development

No branches or pull requests

4 participants