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

[help] Detect if Direct Message on on('message') #301

Closed aDu closed 5 years ago

aDu commented 5 years ago

I am listening on the message event. client.on('message', function(user, userID, channelID, message, event) { });`

On this event, I get a userID that is different to the channelID when the bot receives a direct message. When the bot receives a message on a non-DM channel, it's the same.

How do I differentiate between the bot receiving private messages, and the bot receiving it on any other channel?

Thanks!

Peacerekam commented 5 years ago
if (bot.directMessages[channelID]) {}

or

if (channelID in bot.directMessages) { }

or something similar

aDu commented 5 years ago

Thanks, it's a fantastic API <3.

Edit: Just found it on the docs after reading your comment, I should've read the docs more thoroughly, sorry <3.