Skip to content

Commit

Permalink
Fix bug where if no content for enabled versions was found it could c…
Browse files Browse the repository at this point in the history
…rash
  • Loading branch information
pdellaert committed Oct 20, 2024
1 parent 9c3fad6 commit 384855f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/events/messageCreateHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ export default event(Events.MessageCreate, async (_, message) => {

// Drop execution if the version is disabled and we aren't using the default version for a channel
if (!commandVersionEnabled && !channelDefaultVersionUsed) {
if ((commandCachedVersion || commandVersionExplicitGeneric) && commandTextMatch[2]) {
[commandText] = commandTextMatch.slice(2);
}
Logger.debug(`Prefix Command - Version "${commandVersionName}" is disabled - Not executing command "${commandText}"`);
return;
}
Expand Down Expand Up @@ -252,6 +255,13 @@ export default event(Events.MessageCreate, async (_, message) => {
.sort()
.map((key: string) => versionSelectionButtonData[key]);
const versionSelectButtonRow = new ActionRowBuilder<ButtonBuilder>().addComponents(versionSelectionButtons);

if (versionSelectButtonRow.components.length < 1) {
Logger.debug(`Prefix Command - No enabled versions found for command "${name}" based on user command "${commandText}"`);
Logger.debug(`Prefix Command - Executing version "${commandVersionName}" for command "${name}" based on user command "${commandText}"`);
await sendReply(message, commandTitle, commandContent || '', isEmbed || false, embedColor || constantsConfig.colors.FBW_CYAN, commandImage || '');
return;
}
const buttonMessage = await sendReply(message, commandTitle, commandContent || '', isEmbed || false, embedColor || constantsConfig.colors.FBW_CYAN, commandImage || '', versionSelectButtonRow);

const filter = (interaction: Interaction) => interaction.user.id === authorId;
Expand Down

0 comments on commit 384855f

Please sign in to comment.