From 6480f1725da827f1877519e2b183d245ea7e7cd0 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 20 Sep 2022 20:01:54 -0500 Subject: [PATCH] feat: add disable (#39) --- TypeScript/disable.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 TypeScript/disable.ts diff --git a/TypeScript/disable.ts b/TypeScript/disable.ts new file mode 100644 index 0000000..68efa42 --- /dev/null +++ b/TypeScript/disable.ts @@ -0,0 +1,36 @@ +// @ts-nocheck +/** + * Disables a command entirely, for whatever reasons you may need. + * + * @author @jacoobes [<@182326315813306368>] + * @version 1.0.0 + * @example + * ```ts + * import { disable } from "../plugins/disable"; + * import { commandModule } from "@sern/handler"; + * export default commandModule({ + * plugins: [ disable() ], + * execute: (ctx) => { + * //your code here + * } + * }) + * ``` + */ + import { CommandType, EventPlugin, PluginType } from "@sern/handler"; + import { InteractionReplyOptions, ReplyMessageOptions } from "discord.js"; + + export function disable( + onFail?: string | Omit | ReplyMessageOptions + ): EventPlugin { + return { + type: PluginType.Event, + description: "Disables command from responding", + async execute([ctx], controller) { + if(onFail !== undefined) { + await ctx.reply(onFail); + } + return controller.stop(); + } + }; + } + \ No newline at end of file