mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
fix(InteractionCreateAction): Ensure text-based channel for caching messages (#7755)
* fix: ensure text-based channel for adding messages * fix: account for interaction-only applications The event will emit for these types of bots. However, as the channel is not from a cached guild, they are safe from this crash. * fix: typos * refactor: more descriptive variable usage
This commit is contained in:
@@ -16,9 +16,11 @@ class InteractionCreateAction extends Action {
|
|||||||
const client = this.client;
|
const client = this.client;
|
||||||
|
|
||||||
// Resolve and cache partial channels for Interaction#channel getter
|
// Resolve and cache partial channels for Interaction#channel getter
|
||||||
this.getChannel(data);
|
const channel = this.getChannel(data);
|
||||||
|
|
||||||
|
// Do not emit this for interactions that cache messages that are non-text-based.
|
||||||
let InteractionClass;
|
let InteractionClass;
|
||||||
|
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case InteractionType.ApplicationCommand:
|
case InteractionType.ApplicationCommand:
|
||||||
switch (data.data.type) {
|
switch (data.data.type) {
|
||||||
@@ -29,6 +31,7 @@ class InteractionCreateAction extends Action {
|
|||||||
InteractionClass = UserContextMenuCommandInteraction;
|
InteractionClass = UserContextMenuCommandInteraction;
|
||||||
break;
|
break;
|
||||||
case ApplicationCommandType.Message:
|
case ApplicationCommandType.Message:
|
||||||
|
if (channel && !channel.isTextBased()) return;
|
||||||
InteractionClass = MessageContextMenuCommandInteraction;
|
InteractionClass = MessageContextMenuCommandInteraction;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -40,6 +43,8 @@ class InteractionCreateAction extends Action {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case InteractionType.MessageComponent:
|
case InteractionType.MessageComponent:
|
||||||
|
if (channel && !channel.isTextBased()) return;
|
||||||
|
|
||||||
switch (data.data.component_type) {
|
switch (data.data.component_type) {
|
||||||
case ComponentType.Button:
|
case ComponentType.Button:
|
||||||
InteractionClass = ButtonInteraction;
|
InteractionClass = ButtonInteraction;
|
||||||
|
|||||||
Reference in New Issue
Block a user