From 2f42e8ea780103c63c04eb526b907cd51ff65636 Mon Sep 17 00:00:00 2001 From: Evo <85353424+EvolutionX-10@users.noreply.github.com> Date: Fri, 24 Jun 2022 22:27:47 +0530 Subject: [PATCH] feat: add ownerOnly plugin (#4) --- TypeScript/ownerOnly.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 TypeScript/ownerOnly.ts diff --git a/TypeScript/ownerOnly.ts b/TypeScript/ownerOnly.ts new file mode 100644 index 0000000..d8c46ef --- /dev/null +++ b/TypeScript/ownerOnly.ts @@ -0,0 +1,31 @@ +// @ts-nocheck +/** + * @author: @EvolutionX-10 + * @version: 1.0.0 + * @description: This is OwnerOnly plugin, it allows only bot owners to run the command, like eval. + * @license: MIT + * @example: + * ```ts + * import { OwnerOnly } from "../path/to/your/plugin/folder"; + * import { sernModule, CommandType } from "@sern/handler"; + * export default sernModule([OwnerOnly()], { + * // your code + * }) + * ``` + */ + +import { CommandType, EventPlugin, PluginType } from "@sern/handler"; +const ownerIDs = ["697795666373640213"]; //! Fill your ID +export function ownerOnly(): EventPlugin { + return { + type: PluginType.Event, + description: "Allows only bot owner to run command", + async execute(event, controller) { + const [ctx] = event; + if (ownerIDs.includes(ctx.user.id)) return controller.next(); + //* If you want to reply when the command fails due to user not being owner, you can use following + // await ctx.reply("Only owner can run it!!!"); + return controller.stop(); //! Important: It stops the execution of command! + }, + }; +}