Skip to content

Commit

Permalink
Disabling buttons if it is a fallback to GENERIC version
Browse files Browse the repository at this point in the history
  • Loading branch information
pdellaert committed Oct 17, 2024
1 parent 2e5ea60 commit e95eae2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/events/messageCreateHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,12 @@ export default event(Events.MessageCreate, async (_, message) => {
}

let commandContentData = contents.find(({ versionId }) => versionId === commandVersionId);
let enableButtons = true;
// If the version is not found, try to find the generic version
if (!commandContentData) {
commandContentData = contents.find(({ versionId }) => versionId === 'GENERIC');
commandVersionName = 'GENERIC';
enableButtons = false;
}
// If the generic version is not found, drop execution
if (!commandContentData) {
Expand All @@ -221,7 +223,7 @@ export default event(Events.MessageCreate, async (_, message) => {
// If generic requested and multiple versions, show the selection
// Note that this only applies if GENERIC is the version explicitly requested
// Otherwise, the options are not shown
if (commandVersionName === 'GENERIC' && contents.length > 1) {
if (enableButtons && commandVersionName === 'GENERIC' && contents.length > 1) {
Logger.debug(`Prefix Command - Multiple versions found for command "${name}" based on user command "${commandText}", showing version selection`);
const versionSelectionButtonData: { [key: string]: ButtonBuilder } = {};
for (const { versionId: versionIdForButton } of contents) {
Expand Down

0 comments on commit e95eae2

Please sign in to comment.