mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 10:49:20 +00:00
Fixed select menu bug
This commit is contained in:
@@ -119,7 +119,7 @@ export async function joinVoiceChannelProcedure(
|
|||||||
voiceChannel: VoiceChannel | StageChannel
|
voiceChannel: VoiceChannel | StageChannel
|
||||||
) {
|
) {
|
||||||
const isSlashCommand = data.isApplicationCommand();
|
const isSlashCommand = data.isApplicationCommand();
|
||||||
const isAcceptableInteraction = data.isSelectMenu() || data.isButton();
|
const isAcceptableInteraction = data.isStringSelectMenu() || data.isButton();
|
||||||
const isMessage = data.isMessage();
|
const isMessage = data.isMessage();
|
||||||
if (!isSlashCommand && !isAcceptableInteraction && !isMessage) return;
|
if (!isSlashCommand && !isAcceptableInteraction && !isMessage) return;
|
||||||
|
|
||||||
|
|||||||
@@ -187,8 +187,8 @@ export default class Play extends DiscordModule {
|
|||||||
instance.addTrackToQueue(song);
|
instance.addTrackToQueue(song);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hybridData.getSelectMenu().message instanceof Message)
|
if (hybridData.getStringSelectMenu().message instanceof Message)
|
||||||
await (hybridData.getSelectMenu().message as Message).edit({ components: [] });
|
await (hybridData.getStringSelectMenu().message as Message).edit({ components: [] });
|
||||||
|
|
||||||
return await sendHybridInteractionMessageResponse(
|
return await sendHybridInteractionMessageResponse(
|
||||||
hybridData,
|
hybridData,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
CommandInteraction,
|
CommandInteraction,
|
||||||
ActionRowBuilder,
|
ActionRowBuilder,
|
||||||
ButtonInteraction,
|
ButtonInteraction,
|
||||||
SelectMenuBuilder,
|
StringSelectMenuBuilder,
|
||||||
SelectMenuComponentOptionData
|
SelectMenuComponentOptionData
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { I18n } from 'i18n';
|
import { I18n } from 'i18n';
|
||||||
@@ -137,7 +137,7 @@ export default class Search extends DiscordModule {
|
|||||||
|
|
||||||
const menuOptions: SelectMenuComponentOptionData[] = [];
|
const menuOptions: SelectMenuComponentOptionData[] = [];
|
||||||
|
|
||||||
const messageSelectMenu = new SelectMenuBuilder();
|
const messageSelectMenu = new StringSelectMenuBuilder();
|
||||||
/*
|
/*
|
||||||
Discord have 100 char custom id char limit
|
Discord have 100 char custom id char limit
|
||||||
So we need to shorten our json.
|
So we need to shorten our json.
|
||||||
@@ -168,7 +168,7 @@ export default class Search extends DiscordModule {
|
|||||||
|
|
||||||
messageSelectMenu.addOptions(menuOptions);
|
messageSelectMenu.addOptions(menuOptions);
|
||||||
|
|
||||||
const row = new ActionRowBuilder<SelectMenuBuilder>();
|
const row = new ActionRowBuilder<StringSelectMenuBuilder>();
|
||||||
row.addComponents([messageSelectMenu]);
|
row.addComponents([messageSelectMenu]);
|
||||||
|
|
||||||
return await sendHybridInteractionMessageResponse(data, {
|
return await sendHybridInteractionMessageResponse(data, {
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ class Discord {
|
|||||||
`Triggering 'GuildButtonInteractionCreate' event for module ${thisModule.constructor.name}`
|
`Triggering 'GuildButtonInteractionCreate' event for module ${thisModule.constructor.name}`
|
||||||
);
|
);
|
||||||
thisModule.GuildButtonInteractionCreate(interaction);
|
thisModule.GuildButtonInteractionCreate(interaction);
|
||||||
} else if (interaction.isSelectMenu()) {
|
} else if (interaction.isStringSelectMenu()) {
|
||||||
Logger.verbose(
|
Logger.verbose(
|
||||||
LOGGING_TAG,
|
LOGGING_TAG,
|
||||||
`Triggering 'GuildSelectMenuInteractionCreate' event for module ${thisModule.constructor.name}`
|
`Triggering 'GuildSelectMenuInteractionCreate' event for module ${thisModule.constructor.name}`
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ export async function sendHybridInteractionMessageResponse(
|
|||||||
): Promise<Message | BaseInteraction | undefined> {
|
): Promise<Message | BaseInteraction | undefined> {
|
||||||
Logger.verbose(LOGGING_TAG, `Sending hybrid interaction message response, ${JSON.stringify(payload)})}`);
|
Logger.verbose(LOGGING_TAG, `Sending hybrid interaction message response, ${JSON.stringify(payload)})}`);
|
||||||
|
|
||||||
if (data.isApplicationCommand() || data.isButton() || data.isSelectMenu()) {
|
if (data.isApplicationCommand() || data.isButton() || data.isStringSelectMenu()) {
|
||||||
const messageComponent = data.getMessageComponentInteraction();
|
const messageComponent = data.getMessageComponentInteraction();
|
||||||
|
|
||||||
if (!messageComponent.replied) {
|
if (!messageComponent.replied) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
TextBasedChannel,
|
TextBasedChannel,
|
||||||
MessageComponentInteraction,
|
MessageComponentInteraction,
|
||||||
User,
|
User,
|
||||||
SelectMenuInteraction,
|
StringSelectMenuInteraction,
|
||||||
InteractionType,
|
InteractionType,
|
||||||
BaseInteraction,
|
BaseInteraction,
|
||||||
GuildBasedChannel,
|
GuildBasedChannel,
|
||||||
@@ -46,7 +46,7 @@ export default class DiscordModule {
|
|||||||
GuildCommandInteractionCreate(interaction: CommandInteraction): void | Promise<void | any> {}
|
GuildCommandInteractionCreate(interaction: CommandInteraction): void | Promise<void | any> {}
|
||||||
GuildModuleCommandInteractionCreate(interaction: CommandInteraction): void | Promise<void | any> {}
|
GuildModuleCommandInteractionCreate(interaction: CommandInteraction): void | Promise<void | any> {}
|
||||||
|
|
||||||
GuildSelectMenuInteractionCreate(interaction: SelectMenuInteraction): void | Promise<void | any> {}
|
GuildSelectMenuInteractionCreate(interaction: StringSelectMenuInteraction): void | Promise<void | any> {}
|
||||||
|
|
||||||
GuildButtonInteractionCreate(interaction: ButtonInteraction): void | Promise<void | any> {}
|
GuildButtonInteractionCreate(interaction: ButtonInteraction): void | Promise<void | any> {}
|
||||||
|
|
||||||
@@ -73,8 +73,8 @@ export class HybridInteractionMessage {
|
|||||||
return this.data instanceof ButtonInteraction && this.data.isButton();
|
return this.data instanceof ButtonInteraction && this.data.isButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
public isSelectMenu(): boolean {
|
public isStringSelectMenu(): boolean {
|
||||||
return this.data instanceof SelectMenuInteraction && this.data.isSelectMenu();
|
return this.data instanceof StringSelectMenuInteraction && this.data.isStringSelectMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
public isMessage(): boolean {
|
public isMessage(): boolean {
|
||||||
@@ -117,11 +117,11 @@ export class HybridInteractionMessage {
|
|||||||
return this.data as CommandInteraction;
|
return this.data as CommandInteraction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSelectMenu(): SelectMenuInteraction {
|
public getStringSelectMenu(): StringSelectMenuInteraction {
|
||||||
if (this.isInteraction() && !(this.data as SelectMenuInteraction))
|
if (this.isInteraction() && !(this.data as StringSelectMenuInteraction))
|
||||||
throw new Error('Unable to cast to SelectMenuInteraction');
|
throw new Error('Unable to cast to StringSelectMenuInteraction');
|
||||||
|
|
||||||
return this.data as SelectMenuInteraction;
|
return this.data as StringSelectMenuInteraction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getMessageComponentInteraction(): MessageComponentInteraction {
|
public getMessageComponentInteraction(): MessageComponentInteraction {
|
||||||
|
|||||||
Reference in New Issue
Block a user