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 loses guildId #9754

Closed
Markus-Rost opened this issue Aug 6, 2023 · 0 comments · Fixed by #9755
Closed

Interaction channel loses guildId #9754

Markus-Rost opened this issue Aug 6, 2023 · 0 comments · Fixed by #9755

Comments

@Markus-Rost
Copy link
Contributor

Markus-Rost commented Aug 6, 2023

Which package is this bug report for?

discord.js

Issue description

  1. Run below code snippet
  2. Trigger an interaction in a guild TextChannel (I used slash commands)
  3. Notice how the channel.guildId returns undefined after deferReply

Both the Channel partial as well as the DirectMessages gateway intent are required for this issue to occur. The defer reply also need to be ephemeral. Changing any of those points prevents the issue from happening.

Code sample

import 'dotenv/config';
import Discord from 'discord.js';

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

client.on( Discord.Events.InteractionCreate, interaction => {
	console.log('Partial channel?', interaction.channel?.partial);
	if ( interaction.channel?.partial ) return interaction.channel.fetch().then( () => {
		return interactionCreate(interaction);
	}, log_error );
	return interactionCreate(interaction);
} );

function interactionCreate(interaction) {
	console.log('Before deferReply:', interaction.channel.guildId, interaction.channel.guild.name);
	interaction.deferReply( {ephemeral: true} ).then( () => {
		console.log('After deferReply: ', interaction.channel.guildId, interaction.channel.guild.name);
	} );
}

client.login(process.env.token);

Versions

  • discord.js 14.12.1
  • Node.js 18.16.0
  • NPM 9.8.1
  • Windows 10

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

No response

@Jiralite Jiralite self-assigned this Aug 6, 2023
@Jiralite Jiralite added the has PR label Aug 6, 2023
@kodiakhq kodiakhq bot closed this as completed in #9755 Aug 11, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants