mirror of
https://github.com/sern-handler/awesome-plugins
synced 2026-06-27 18:22:17 +00:00
feat: add disable (#39)
This commit is contained in:
36
TypeScript/disable.ts
Normal file
36
TypeScript/disable.ts
Normal file
@@ -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<InteractionReplyOptions, "fetchReply"> | ReplyMessageOptions
|
||||
): EventPlugin<CommandType.Both> {
|
||||
return {
|
||||
type: PluginType.Event,
|
||||
description: "Disables command from responding",
|
||||
async execute([ctx], controller) {
|
||||
if(onFail !== undefined) {
|
||||
await ctx.reply(onFail);
|
||||
}
|
||||
return controller.stop();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user