Skip to content

Commit

Permalink
feat: allow dynamic button actions
Browse files Browse the repository at this point in the history
Mirasaki committed Apr 14, 2023
1 parent 169d819 commit abfb331
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/listeners/interaction/interactionCreate.js
Original file line number Diff line number Diff line change
@@ -56,14 +56,20 @@ const getCommand = (client, activeId) => {
|| selectMenus.get(activeId);
};

// eslint-disable-next-line sonarjs/cognitive-complexity
const runCommand = (client, interaction, activeId, cmdRunTimeStart) => {
const {
member, guild, channel
} = interaction;
const clientCmd = getCommand(client, activeId);
let clientCmd = getCommand(client, activeId);

// Early escape hatch for in-command components
if (activeId.startsWith('@')) return;
if (activeId.startsWith('@')) {
const secondAtSignIndex = activeId.indexOf('@', 1);
const sliceEndIndex = secondAtSignIndex >= 0 ? secondAtSignIndex : activeId.length;
const dynamicCmd = clientCmd = getCommand(client, activeId.slice(1, sliceEndIndex));
if (!dynamicCmd) return; // Should be ignored
}

// Check for late API changes
if (!clientCmd) {

0 comments on commit abfb331

Please sign in to comment.