izy521 / discord.io

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

Cannot read property 'members' of undefined #309

Open JohnYuZhang opened 5 years ago

JohnYuZhang commented 5 years ago

I want to retreive a member status of a specific member through:

var bot = new Discord.Client({
   token: auth.token,
   autorun: true
});
bot.on('ready', function (evt) {
    logger.info('Connected');
    logger.info('Logged in as: ');
    logger.info(bot.username + ' - (' + bot.id + ')');
    console.log(bot.servers[data.serverID].members[data.userID].status)
});

(assuming this is now you get the server id) image

but it says the members object is undefined.

I've also tried: bot.getMember(data,function(err,res){console.log(err)} ) which returns an unauthorized error. name: 'ResponseError', statusCode: 401, statusMessage: 'UNAUTHORIZED', response: { code: 0, message: '401: Unauthorized' } }

The example files on message and presence work fine without any authorization errors.