You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When fetching a closed thread with allowUnknownGuild set to true, messages fetched in that channel will have no guild, no guildId, and Message.inGuild() will return false, even if the channel itself has a guild. This seems to happen for all closed threads. Setting allowUnknownGuild to false or omitting it entirely prevents the issue from happening.
Steps to reproduce:
Create a thread in a server with your bot
Close the thread
Copy the thread ID into the code sample below
Expected behaviour:
The thread is in a guild, and thread.guild returns the guild, so, logically, each message should also have a guild.
Actual behaviour:
The messages don't have a guild, and isGuild returns false. The console.log is executed.
Code sample
import{Client,GatewayIntentBits}from"discord.js"consttoken="BOT_TOKEN"constclosedThreadId="CHANNEL_ID"constclient=newClient({intents: [GatewayIntentBits.Guilds,GatewayIntentBits.GuildMembers,GatewayIntentBits.GuildMessages,GatewayIntentBits.MessageContent,],})client.addListener("ready",async()=>{constthread=awaitclient.channels.fetch(closedThreadId,{allowUnknownGuild: true,})if(!thread||!thread.isThread()||!thread.archived){awaitclient.destroy()thrownewError("Invalid channel")}constmessages=awaitthread.messages.fetch()if(thread.guild&&!messages.every((message)=>message.inGuild())){console.log("Despite the channel having a guild, the messages aren't inGuild",)}awaitclient.destroy()})awaitclient.login(token)
Which package is this bug report for?
discord.js
Issue description
When fetching a closed thread with
allowUnknownGuild
set totrue
, messages fetched in that channel will have noguild
, noguildId
, andMessage.inGuild()
will returnfalse
, even if the channel itself has aguild
. This seems to happen for all closed threads. SettingallowUnknownGuild
tofalse
or omitting it entirely prevents the issue from happening.Steps to reproduce:
Expected behaviour:
The thread is in a guild, and
thread.guild
returns the guild, so, logically, each message should also have a guild.Actual behaviour:
The messages don't have a guild, and isGuild returns false. The
console.log
is executed.Code sample
Versions
Issue priority
Low (slightly annoying)
Which partials do you have configured?
No Partials
Which gateway intents are you subscribing to?
Guilds, GuildMembers, GuildMessages, MessageContent
I have tested this issue on a development release
efa3cac
The text was updated successfully, but these errors were encountered: