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

client.getOfflineUsers() is not a function #305

Closed KriskotooBG closed 5 years ago

KriskotooBG commented 5 years ago

Hi, Recently I wanted to make the bot get the count of users and display it as a channel name after reading the documentation I found out about the client.getOfflineUsers() unfortunately when I tried to use it, my bot crashed every time with the error "client.getOfflineUsers(callback) is not a function" also I didn't see a method that allows you to rename a text channel. Any help is appreciated!

Peacerekam commented 5 years ago

Use those docs: (link goes to bot.editChannelInfo which will let you change the text channel name) https://izy521.github.io/discord.io-docs/Discord.Client.html#editChannelInfo

bot.getOfflineUsers doesn't exist, try bot.getAllUsers() instead (although you shouldnt need to do it unless you are in a very big server)

number of members is already cached in your bot - Object.keys(bot.servers[serverID].members).length or bot.servers[serverID].member_count

KriskotooBG commented 5 years ago

works like a charm! i guess i was reading the old docs on gitbooks haha... Thanks!

cloudrac3r commented 5 years ago

Note about getAllUsers:

getAllUsers does not take a callback. Instead, it emits the allUsers event.

You should execute bot.getAllUsers() only once, inside the bot.on("ready" function. Then, you should move everything else from the bot.on("ready" function to bot.on("allUsers".