From 8817e2dff71f4736f4f8c9011457d20e63ec4ca3 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 12 Oct 2022 22:22:37 +0200 Subject: [PATCH] Reorganise command plugins --- src/plugins/echo.ts | 23 ----------------------- src/plugins/lenny.ts | 20 -------------------- src/plugins/moreCommands.ts | 37 +++++++++++++++++++++++++++++++++++++ src/plugins/petpet.ts | 8 ++++---- src/plugins/uwuify.ts | 35 +++++++++-------------------------- 5 files changed, 50 insertions(+), 73 deletions(-) delete mode 100644 src/plugins/echo.ts delete mode 100644 src/plugins/lenny.ts create mode 100644 src/plugins/moreCommands.ts diff --git a/src/plugins/echo.ts b/src/plugins/echo.ts deleted file mode 100644 index 9e79800f..00000000 --- a/src/plugins/echo.ts +++ /dev/null @@ -1,23 +0,0 @@ -import definePlugin from "../utils/types"; -import { ApplicationCommandInputType, sendBotMessage, findOption, OptionalMessageOption } from "../api/Commands"; -import { ReactionEmoji, Message, MessageReaction, JSMessage } from "discord-types/general"; - -export default definePlugin({ - name: "Echo", - description: "Uses Clydes message function to send a custom message of your choice (locally)", - authors: [{ name: "ICodeInAssembly", id: 702973430449832038n }], - dependencies: ["CommandsAPI"], - commands: [ - { - name: "echo", - description: "Sends a message as Clyde (locally)", - options: [OptionalMessageOption], - inputType: ApplicationCommandInputType.BOT, - execute: (opts, ctx) => { - const message = findOption(opts, "message", ""); - - sendBotMessage(ctx.channel.id, { content: message }); - }, - }, - ] -}); diff --git a/src/plugins/lenny.ts b/src/plugins/lenny.ts deleted file mode 100644 index 1877752b..00000000 --- a/src/plugins/lenny.ts +++ /dev/null @@ -1,20 +0,0 @@ -import definePlugin from "../utils/types"; -import { Devs } from "../utils/constants"; -import { findOption, OptionalMessageOption } from "../api/Commands"; - -export default definePlugin({ - name: "lenny", - description: "( ͡° ͜ʖ ͡°)", - authors: [Devs.Arjix], - dependencies: ["CommandsAPI"], - commands: [ - { - name: "lenny", - description: "Sends a lenny face", - options: [OptionalMessageOption], - execute: opts => ({ - content: findOption(opts, "message", "") + " ( ͡° ͜ʖ ͡°)" - }), - }, - ] -}); diff --git a/src/plugins/moreCommands.ts b/src/plugins/moreCommands.ts new file mode 100644 index 00000000..91c1abb1 --- /dev/null +++ b/src/plugins/moreCommands.ts @@ -0,0 +1,37 @@ +import definePlugin from "../utils/types"; +import { ApplicationCommandInputType, sendBotMessage, findOption, OptionalMessageOption } from "../api/Commands"; +import { Devs } from "../utils/constants"; + +export default definePlugin({ + name: "MoreCommands", + description: "echo, lenny", + authors: [ + Devs.Arjix, + { + name: "ICodeInAssembly", + id: 702973430449832038n + } + ], + dependencies: ["CommandsAPI"], + commands: [ + { + name: "echo", + description: "Sends a message as Clyde (locally)", + options: [OptionalMessageOption], + inputType: ApplicationCommandInputType.BOT, + execute: (opts, ctx) => { + const content = findOption(opts, "message", ""); + + sendBotMessage(ctx.channel.id, { content }); + }, + }, + { + name: "lenny", + description: "Sends a lenny face", + options: [OptionalMessageOption], + execute: opts => ({ + content: findOption(opts, "message", "") + " ( ͡° ͜ʖ ͡°)" + }), + }, + ] +}); diff --git a/src/plugins/petpet.ts b/src/plugins/petpet.ts index 6b0fd4f0..0c4c29b1 100644 --- a/src/plugins/petpet.ts +++ b/src/plugins/petpet.ts @@ -1,7 +1,7 @@ import { ApplicationCommandOptionType, findOption, ApplicationCommandInputType, Argument, CommandContext } from "../api/Commands"; import { Devs } from "../utils/constants"; import definePlugin from "../utils/types"; -import { lazy, lazyWebpack, suppressErrors } from "../utils/misc"; +import { lazy, lazyWebpack } from "../utils/misc"; import { filters } from "../webpack"; const DRAFT_TYPE = 0; @@ -36,7 +36,7 @@ function loadImage(source: File | string) { URL.revokeObjectURL(url); resolve(img); }; - img.onerror = reject; + img.onerror = (event, _source, _lineno, _colno, err) => reject(err || event); img.crossOrigin = "Anonymous"; img.src = url; }); @@ -109,7 +109,7 @@ export default definePlugin({ type: ApplicationCommandOptionType.BOOLEAN } ], - execute: suppressErrors("petpetExecute", async (opts, cmdCtx) => { + execute: async (opts, cmdCtx) => { const { GIFEncoder, quantize, applyPalette } = await getGifEncoder(); const frames = await getFrames(); @@ -162,7 +162,7 @@ export default definePlugin({ // Immediately after the command finishes, Discord clears all input, including pending attachments. // Thus, setImmediate is needed to make this execute after Discord cleared the input setImmediate(() => promptToUpload([file], cmdCtx.channel, DRAFT_TYPE)); - }), + }, }, ] }); diff --git a/src/plugins/uwuify.ts b/src/plugins/uwuify.ts index 8c8d790b..2cf0f763 100644 --- a/src/plugins/uwuify.ts +++ b/src/plugins/uwuify.ts @@ -1,32 +1,13 @@ import definePlugin from "../utils/types"; import { findOption, RequiredMessageOption } from "../api/Commands"; -// words have a chance of ending with these const endings = [ - "owo", - "UwU", - ">w<", - "^w^", - "●w●", - "☆w☆", - "𝗨𝘄𝗨", - "(ᗒᗨᗕ)", - "(▰˘v˘▰)", - "( ´ ▽ ` ).。o♡", - "*unbuttons shirt*", - ">3<", - ">:3", - ":3", - "murr~", - "♥(。U ω U。)", - "(˘ε˘)", - "*screams*", - "*twerks*", - "*sweats*", + "owo", "UwU", ">w<", "^w^", "●w●", "☆w☆", "𝗨𝘄𝗨", "(ᗒᗨᗕ)", "(▰˘v˘▰)", + "( ´ ▽ ` ).。o♡", "*unbuttons shirt*", ">3<", ">:3", ":3", "murr~", + "♥(。U ω U。)", "(˘ε˘)", "*screams*", "*twerks*", "*sweats*", ]; -// replacement words -const words = [ +const replacements = [ ["love", "wuv"], ["mr", "mistuh"], ["dog", "doggo"], @@ -45,7 +26,6 @@ const words = [ ]; -// uwuify command function uwuify(message: string): string { return message .split(" ") @@ -58,7 +38,7 @@ function uwuify(message: string): string { } // replacing the words based on the array on line 29 - for (let [find, replace] of words) { + for (let [find, replace] of replacements) { if (w.includes(find)) { w = w.replace(find, replace); owofied = true; @@ -111,7 +91,10 @@ function uwuify(message: string): string { export default definePlugin({ name: "UwUifier", description: "Simply uwuify commands", - authors: [{ name: "ECHO", id: 712639419785412668n }], + authors: [{ + name: "ECHO", + id: 712639419785412668n + }], dependencies: ["CommandsAPI"], commands: [