izy521 / discord.io

A small, single-file library for creating DiscordApp clients from Node.js or the browser
https://discord.gg/0MvHMfHcTKVVmIGP
MIT License
534 stars 155 forks source link

bot.users[userID] undefined #156

Closed Wingysam closed 7 years ago

Wingysam commented 7 years ago

I have bot.users[userID].bot in my bot.on('message'), and it's sometimes undefined. Not always. I hope this is enough to reproduce.

izy521 commented 7 years ago

Are you running the script under a created bot account, or your (or any) user account?

Wingysam commented 7 years ago

I'm running it under a bot account, created by me.

PassTheMayo commented 7 years ago

I've had the same issue for the longest time.

ghost commented 7 years ago

@Wingysam The dIO.users object can sometimes be unstable if your bot does not have a good internet connection, could you please give reproducible steps to recreate the issue you are experiencing.

Also, are you using a selfbot/userbot?

Edit: Apparently I cant read, try doing dIO.servers[guildid]['members'][userID].bot as using dIO.servers is alot more stable than dIO.users

izy521 commented 7 years ago

client.users should be stable enough, I'm not sure if I set the bot property of a user who isn't a bot, I'll have to check and edit that later, however if that's the case, just change your code to something like if (bot.users[userID].bot) { /*The user is a bot*/ }.