My bot seems to not received the event "interactionCreate" from button sent in DM

Hello, My bot has sent a message to a user with a button but when the user click on the button the bot doesn't receive the interactionCreate event and an error is shown under the button on the user's app Code that send the message
await user.send({
embeds: [
{
description: `Vous venez d'être banni du serveur **${guild.name}**.\n\n`
+ `**Raison** : ${ctx.data.reason}\n`
+ `**Durée** : ${ctx.data.durationInSec > 0 ? formatDuration(ctx.data.durationInSec, "seconds") : "Infini"}`,
color: COLOR_RED
}
],
components: [{
type: ComponentType.ActionRow,
components: [
{
type: ComponentType.Button,
style: ButtonStyle.Primary,
label: "Contester / Demander un débanissement",
custom_id: "contest_sanction"
}
]
}]
})
await user.send({
embeds: [
{
description: `Vous venez d'être banni du serveur **${guild.name}**.\n\n`
+ `**Raison** : ${ctx.data.reason}\n`
+ `**Durée** : ${ctx.data.durationInSec > 0 ? formatDuration(ctx.data.durationInSec, "seconds") : "Infini"}`,
color: COLOR_RED
}
],
components: [{
type: ComponentType.ActionRow,
components: [
{
type: ComponentType.Button,
style: ButtonStyle.Primary,
label: "Contester / Demander un débanissement",
custom_id: "contest_sanction"
}
]
}]
})
The user correctly receives the message Handler event
// Code from guide
client.on(Events.InteractionCreate, readyClient => {
console.log("hey")
});
// Code from guide
client.on(Events.InteractionCreate, readyClient => {
console.log("hey")
});
- NodeJS :white_right_arrow: v20.14.0 - DiscordJS :white_right_arrow: 14.15.3
9 Replies
d.js toolkit
d.js toolkit5mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Apokalypt
ApokalyptOP5mo ago
And intents are as follow :
intents: [
GatewayIntentBits.MessageContent,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.AutoModerationExecution
]
intents: [
GatewayIntentBits.MessageContent,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.AutoModerationExecution
]
NyR
NyR5mo ago
I'm not sure if this affects interactions, but try enabling Channel partial (also you are only listening it to it once, idk if that was intentional)
Apokalypt
ApokalyptOP5mo ago
I have the following partials enabled : partials: [Partials.Message, Partials.Reaction, Partials.GuildMember, Partials.ThreadMember, Partials.Channel]
(also you are only listening it to it once, idk if that was intentional)
Yes it was just for testing 😂 I changed it to "on" to avoid people saying "hey it's because you already received an event" (which is not the case)
NyR
NyR5mo ago
Intents shouldn't matter with interactions, because it requires none. Idk what could be the issue other than perhaps the listener not being created ig? Where do you create the listener?
Apokalypt
ApokalyptOP5mo ago
Oh wait.... If the user and my bot doesn't share a server in common, my bot can receive interactionCreate events and answer ? Or is it same as messages and it's blocked ?
NyR
NyR5mo ago
If they don't share a common server, you wouldn't be able to send a message in the first place
Apokalypt
ApokalyptOP5mo ago
The message is sent and THEN the user is banned/kick from the guild. The button was put to allow the user to contest the sanction later but I think I can't do that 😭 Forgot to answer but the event is created after I've made new Client(...) (and before login) and the listener is created because I receive interaction from commands
NyR
NyR5mo ago
Idk, that could be the case, haven't encountered this specific situation myself to say for sure. But thinking rationally, if that were the case, buttons sent by user apps wouldn't work either, though there could be a different scenarios for it. Again, this is me just guessing though, i can't say for sure
Want results from more Discord servers?
Add your server