Reorganise command plugins

This commit is contained in:
Vendicated 2022-10-12 22:22:37 +02:00
parent 267b2b1a07
commit 8817e2dff7
No known key found for this signature in database
GPG key ID: EC781ADFB93EFFA3
5 changed files with 50 additions and 73 deletions

View file

@ -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 });
},
},
]
});

View file

@ -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", "") + " ( ͡° ͜ʖ ͡°)"
}),
},
]
});

View file

@ -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", "") + " ( ͡° ͜ʖ ͡°)"
}),
},
]
});

View file

@ -1,7 +1,7 @@
import { ApplicationCommandOptionType, findOption, ApplicationCommandInputType, Argument, CommandContext } from "../api/Commands"; import { ApplicationCommandOptionType, findOption, ApplicationCommandInputType, Argument, CommandContext } from "../api/Commands";
import { Devs } from "../utils/constants"; import { Devs } from "../utils/constants";
import definePlugin from "../utils/types"; import definePlugin from "../utils/types";
import { lazy, lazyWebpack, suppressErrors } from "../utils/misc"; import { lazy, lazyWebpack } from "../utils/misc";
import { filters } from "../webpack"; import { filters } from "../webpack";
const DRAFT_TYPE = 0; const DRAFT_TYPE = 0;
@ -36,7 +36,7 @@ function loadImage(source: File | string) {
URL.revokeObjectURL(url); URL.revokeObjectURL(url);
resolve(img); resolve(img);
}; };
img.onerror = reject; img.onerror = (event, _source, _lineno, _colno, err) => reject(err || event);
img.crossOrigin = "Anonymous"; img.crossOrigin = "Anonymous";
img.src = url; img.src = url;
}); });
@ -109,7 +109,7 @@ export default definePlugin({
type: ApplicationCommandOptionType.BOOLEAN type: ApplicationCommandOptionType.BOOLEAN
} }
], ],
execute: suppressErrors("petpetExecute", async (opts, cmdCtx) => { execute: async (opts, cmdCtx) => {
const { GIFEncoder, quantize, applyPalette } = await getGifEncoder(); const { GIFEncoder, quantize, applyPalette } = await getGifEncoder();
const frames = await getFrames(); const frames = await getFrames();
@ -162,7 +162,7 @@ export default definePlugin({
// Immediately after the command finishes, Discord clears all input, including pending attachments. // 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 // Thus, setImmediate is needed to make this execute after Discord cleared the input
setImmediate(() => promptToUpload([file], cmdCtx.channel, DRAFT_TYPE)); setImmediate(() => promptToUpload([file], cmdCtx.channel, DRAFT_TYPE));
}), },
}, },
] ]
}); });

View file

@ -1,32 +1,13 @@
import definePlugin from "../utils/types"; import definePlugin from "../utils/types";
import { findOption, RequiredMessageOption } from "../api/Commands"; import { findOption, RequiredMessageOption } from "../api/Commands";
// words have a chance of ending with these
const endings = [ const endings = [
"owo", "owo", "UwU", ">w<", "^w^", "●w●", "☆w☆", "𝗨𝘄𝗨", "(ᗒᗨᗕ)", "(▰˘v˘▰)",
"UwU", "( ´ ▽ ` ).。o♡", "*unbuttons shirt*", ">3<", ">:3", ":3", "murr~",
">w<", "♥(。U ω U。)", "(˘ε˘)", "*screams*", "*twerks*", "*sweats*",
"^w^",
"●w●",
"☆w☆",
"𝗨𝘄𝗨",
"(ᗒᗨᗕ)",
"(▰˘v˘▰)",
"( ´ ▽ ` ).。o♡",
"*unbuttons shirt*",
">3<",
">:3",
":3",
"murr~",
"♥(。U ω U。)",
"(˘ε˘)",
"*screams*",
"*twerks*",
"*sweats*",
]; ];
// replacement words const replacements = [
const words = [
["love", "wuv"], ["love", "wuv"],
["mr", "mistuh"], ["mr", "mistuh"],
["dog", "doggo"], ["dog", "doggo"],
@ -45,7 +26,6 @@ const words = [
]; ];
// uwuify command
function uwuify(message: string): string { function uwuify(message: string): string {
return message return message
.split(" ") .split(" ")
@ -58,7 +38,7 @@ function uwuify(message: string): string {
} }
// replacing the words based on the array on line 29 // 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)) { if (w.includes(find)) {
w = w.replace(find, replace); w = w.replace(find, replace);
owofied = true; owofied = true;
@ -111,7 +91,10 @@ function uwuify(message: string): string {
export default definePlugin({ export default definePlugin({
name: "UwUifier", name: "UwUifier",
description: "Simply uwuify commands", description: "Simply uwuify commands",
authors: [{ name: "ECHO", id: 712639419785412668n }], authors: [{
name: "ECHO",
id: 712639419785412668n
}],
dependencies: ["CommandsAPI"], dependencies: ["CommandsAPI"],
commands: [ commands: [