From bb0a82a2536635bf3104e6f4a7cf20812882ffc1 Mon Sep 17 00:00:00 2001 From: Peter-MJ-Parker <34216187+Peter-MJ-Parker@users.noreply.github.com> Date: Wed, 22 Feb 2023 17:54:26 -0600 Subject: [PATCH 1/2] Peter mj parker patch 1 (#83) * feat: Update plugin `disable` Updates PluginType to work with new typings for sern v2. Application does not fail to respond when no fail message is defined. * fix: Resolve changes Setup the timeout differently and added notes to explain what the functions do. --- TypeScript/disable.ts | 57 +++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/TypeScript/disable.ts b/TypeScript/disable.ts index 5fc2f1f..f8432fa 100644 --- a/TypeScript/disable.ts +++ b/TypeScript/disable.ts @@ -3,7 +3,8 @@ * Disables a command entirely, for whatever reasons you may need. * * @author @jacoobes [<@182326315813306368>] - * @version 1.0.0 + * @author @Peter-MJ-Parker [<@1017182455926624316>] + * @version 2.0.0 * @example * ```ts * import { disable } from "../plugins/disable"; @@ -16,23 +17,53 @@ * }) * ``` */ -import { CommandType, EventPlugin, PluginType } from "@sern/handler"; -import { InteractionReplyOptions, ReplyMessageOptions } from "discord.js"; +import { CommandType, CommandControlPlugin, controller } from "@sern/handler"; +import { + InteractionReplyOptions, + Message, + 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 CommandControlPlugin(async (ctx, [args]) => { + if (onFail !== undefined) { + switch (args) { + case "text": + //reply to text command + const msg = await ctx.reply(onFail); + setTimeout(() => { + //deletes the bots reply to the user + msg.delete(); + //deletes the original authors message (text command). + ctx.message.delete(); + //waits 5 seconds before deleting messages + }, 5000).catch((e) => { + //logs error to console (if any). + console.log(e); + }); + + break; + + case "slash": + //ephemeral response to say the command is disabled with users response. + await ctx.reply({ content: onFail, ephemeral: true }); + break; + + default: + break; } - return controller.stop(); - }, - }; + } + //this function tells the bot to reply to an interaction so it doesn't seem like it fails (in case there is no onFail message). + if (onFail === undefined && args === "slash") { + onFail = "This command is disabled."; + await ctx.reply({ content: onFail, ephemeral: true }); + } + //stop the command from running + return controller.stop(); + }); } From 9da1fd721fd759386814e417bc019dd5cc8775f8 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Wed, 22 Feb 2023 21:14:21 -0600 Subject: [PATCH 2/2] chore: update ci (#85) --- .github/workflows/gen-list.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/gen-list.yml b/.github/workflows/gen-list.yml index ca97f88..19b96c5 100644 --- a/.github/workflows/gen-list.yml +++ b/.github/workflows/gen-list.yml @@ -1,9 +1,6 @@ name: "Generate Plugin Listing" on: - push: - branches: - main workflow_dispatch: jobs: