Context Menu Actions v1, clean and mute support with full options
This commit is contained in:
parent
2281dbcfef
commit
ff774aa5f6
19 changed files with 657 additions and 152 deletions
28
backend/src/plugins/ContextMenus/utils/contextRouter.ts
Normal file
28
backend/src/plugins/ContextMenus/utils/contextRouter.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import { ContextMenuInteraction } from "discord.js";
|
||||
import { GuildPluginData } from "../../../../../../Knub/dist";
|
||||
import { availableActions } from "../actions/availableActions";
|
||||
import { ContextMenuPluginType } from "../types";
|
||||
|
||||
export async function routeContextAction(
|
||||
pluginData: GuildPluginData<ContextMenuPluginType>,
|
||||
interaction: ContextMenuInteraction,
|
||||
) {
|
||||
const contextLink = await pluginData.state.contextMenuLinks.get(interaction.commandId);
|
||||
if (!contextLink) return;
|
||||
const contextActions = Object.entries(pluginData.config.get().context_actions);
|
||||
|
||||
const configLink = contextActions.find(x => x[0] === contextLink.action_name);
|
||||
if (!configLink) return;
|
||||
|
||||
for (const [actionName, actionConfig] of Object.entries(configLink[1].action)) {
|
||||
if (actionConfig == null) return;
|
||||
const action = availableActions[actionName];
|
||||
action.apply({
|
||||
actionName,
|
||||
pluginData,
|
||||
actionConfig,
|
||||
interaction,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue