Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interaction.channel.guildId undefined after ephemeral reply #10495

Closed
edocsil47 opened this issue Sep 8, 2024 · 0 comments · Fixed by #10505
Closed

interaction.channel.guildId undefined after ephemeral reply #10495

edocsil47 opened this issue Sep 8, 2024 · 0 comments · Fixed by #10505

Comments

@edocsil47
Copy link

Which package is this bug report for?

discord.js

Issue description

Responding to interactions with an ephemeral message sometimes sets GuildChannel.guildId to undefined.

After updating to v14.16.1 I've noticed that sometimes when responding to an interaction with an ephemeral message, the guildId of the channel in the cache becomes set to undefined. I was able to create a minimum reproducible example below, but the behavior is still inconsistent. The issue can occur on the first interaction of a session or in subsequent ones.

Logging output 1:
image

Logging output 2:
image

From my testing it seems to require both the DirectMessages intent and the Channel partial. The application is installed in the guild and its bot user has view message permissions in the channel.

In a help thread I created, Syjalo identified the issue was in GuildChannel.js:68:

The issue is in GuildChannel.js:68
Sometimes the data have guild_id property, but with value of undefined.

I've put the issue as "medium" priority since it broke existing v14.15.3 code, but does have workarounds like using GuildChannel.guild.id instead.

TIA.

Code sample

const { Client, Events, GatewayIntentBits, Partials } = require("discord.js")
const { token } = require("./config.json")

const client = new Client({
    intents: [
        GatewayIntentBits.DirectMessages,
        GatewayIntentBits.Guilds,
    ],
    partials: [
        Partials.Channel,
    ],
})

client.on(Events.InteractionCreate, async interaction => {
    console.log(interaction.channel.guildId) // pass
    await interaction.reply({ content: "content", ephemeral: true })
    console.log(interaction.channel.guildId) // sometimes undefined
    console.log(interaction.client.channels.resolve(interaction.channelId).guildId) // same
})

client.login(token)

Versions

discord.js v14.16.1
node v20.17.0
TypeScript N/A
OS Windows 11 23H2

Issue priority

Medium (should be fixed soon)

Which partials do you have configured?

Channel

Which gateway intents are you subscribing to?

Guilds, DirectMessages

I have tested this issue on a development release

1725667851-8a74f144a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants