Closed TheLittlePolaris closed 4 years ago
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
}
Okay, so I have the same issue and for some reason @On('ready')
gets called twice.
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 ?
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
Yes you have to use the client parameter on the event function :)
Thank's @Fredi100 for the support!
Problem:
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:
Much appreciate if you can fix it in the near feature :)