Sopur / Discord-user-bots

Working discord user bots library.
MIT License
85 stars 36 forks source link

Missing properties on channels #43

Closed rudy3333 closed 4 months ago

rudy3333 commented 1 year ago

currently, {channel.name} and for {channel.id} for forum posts are undefined. i guess if someone would be good enough to add support for them i would be greatful

code :

client.on.message_create = function (message) {
       const guild = client.info.guilds.filter((guild) => guild.id == message.guild_id)[0];
       const channel = guild.channels.filter((channel) => channel.id == message.channel_id)[0];

       if (guild.name == "instaling fresh bot")
       console.log(`[${guild.name}] [#${channel.id}] ${message.author.username}: ${message.content}`);
   };

input : image

expected output : [instaling fresh bot] [(thread id) #1102685991933853746] rudy3: ur such a nerd 🤓 actual output :

console.log(`[${guild.name}] [#${channel.id}] ${message.author.username}: ${message.content}`);

TypeError: Cannot read properties of undefined (reading 'id')
    at client.on.message_create (C:\Users\mmax3\Downloads\NanaEmojiDecipher\main.js:16:49)
    at WebSocket.<anonymous> (C:\Users\mmax3\Downloads\NanaEmojiDecipher\node_modules\discord-user- 
    bots\src\client\client.js:374:37)
rudy3333 commented 1 year ago

Update : Using message.channel_id seems to do the trick,

Sopur commented 4 months ago

Discord is very inconsistent with their own API. DUB does not have any structures defined for Discord, so all data that is passed by DUB is raw body data from Discord.