mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-14 13:55:03 +00:00
Change ContextMenu to hardcoded default actions
Sadge (More complex self-defined stuff coming at some point tho)
This commit is contained in:
parent
3ddfb3b65a
commit
7cf75f3255
12 changed files with 183 additions and 272 deletions
|
@ -1,22 +1,25 @@
|
|||
import { ApplicationCommandData } from "discord.js";
|
||||
import { LogType } from "src/data/LogType";
|
||||
import { LogsPlugin } from "src/plugins/Logs/LogsPlugin";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { LogsPlugin } from "../../../plugins/Logs/LogsPlugin";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { ContextMenuPluginType, ContextMenuTypeNameToNumber } from "../types";
|
||||
import { ContextMenuPluginType } from "../types";
|
||||
import { hardcodedContext } from "./hardcodedContextOptions";
|
||||
|
||||
export async function loadAllCommands(pluginData: GuildPluginData<ContextMenuPluginType>) {
|
||||
const comms = await pluginData.client.application!.commands;
|
||||
const actions = pluginData.config.get().context_actions;
|
||||
const cfg = pluginData.config.get();
|
||||
const newCommands: ApplicationCommandData[] = [];
|
||||
const addedNames: string[] = [];
|
||||
|
||||
for (const [name, configAction] of Object.entries(actions)) {
|
||||
if (!configAction.enabled) continue;
|
||||
for (const [name, label] of Object.entries(hardcodedContext)) {
|
||||
if (!cfg[name]) continue;
|
||||
|
||||
const type = name.startsWith("user") ? 2 : 3;
|
||||
const data: ApplicationCommandData = {
|
||||
type: ContextMenuTypeNameToNumber[configAction.type],
|
||||
name: configAction.label,
|
||||
type,
|
||||
name: label,
|
||||
};
|
||||
|
||||
addedNames.push(name);
|
||||
newCommands.push(data);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue