diff options
author | PandaNinjas <admin@malwarefight.gq> | 2023-05-22 18:13:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-23 03:13:21 +0200 |
commit | 9d62dec6b94996a08b95ced8c6ee21af69d07140 (patch) | |
tree | 96875d4ede93c84936518fca95f64565a26bc337 /src | |
parent | 6bf6583e7d2aaa73cf575504760876f4fa985ee2 (diff) | |
download | Vencord-9d62dec6b94996a08b95ced8c6ee21af69d07140.tar.gz Vencord-9d62dec6b94996a08b95ced8c6ee21af69d07140.tar.bz2 Vencord-9d62dec6b94996a08b95ced8c6ee21af69d07140.zip |
Uwufy: Add option to uwufy all messages (#1036)
Co-authored-by: V <vendicated@riseup.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/uwuify.ts | 37 | ||||
-rw-r--r-- | src/utils/constants.ts | 4 |
2 files changed, 38 insertions, 3 deletions
diff --git a/src/plugins/uwuify.ts b/src/plugins/uwuify.ts index c3a879c..aa38167 100644 --- a/src/plugins/uwuify.ts +++ b/src/plugins/uwuify.ts @@ -17,8 +17,10 @@ */ import { findOption, RequiredMessageOption } from "@api/Commands"; +import { addPreEditListener, addPreSendListener, MessageObject, removePreEditListener, removePreSendListener } from "@api/MessageEvents"; +import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; +import definePlugin, { OptionType } from "@utils/types"; const endings = [ "rawr x3", @@ -65,6 +67,15 @@ const replacements = [ ["meow", "nya~"], ]; +const settings = definePluginSettings({ + uwuEveryMessage: { + description: "Make every single message uwuified", + type: OptionType.BOOLEAN, + default: false, + restartNeeded: false + } +}); + function selectRandomElement(arr) { // generate a random index based on the length of the array const randomIndex = Math.floor(Math.random() * arr.length); @@ -94,8 +105,9 @@ function uwuify(message: string): string { export default definePlugin({ name: "UwUifier", description: "Simply uwuify commands", - authors: [Devs.echo, Devs.skyevg], - dependencies: ["CommandsAPI"], + authors: [Devs.echo, Devs.skyevg, Devs.PandaNinjas], + dependencies: ["CommandsAPI", "MessageEventsAPI"], + settings, commands: [ { @@ -108,4 +120,23 @@ export default definePlugin({ }), }, ], + + onSend(msg: MessageObject) { + // Only run when it's enabled + if (settings.store.uwuEveryMessage) { + msg.content = uwuify(msg.content); + } + }, + + start() { + this.preSend = addPreSendListener((_, msg) => this.onSend(msg)); + this.preEdit = addPreEditListener((_cid, _mid, msg) => + this.onSend(msg) + ); + }, + + stop() { + removePreSendListener(this.preSend); + removePreEditListener(this.preEdit); + }, }); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 9671ac3..91c5929 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -299,6 +299,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "carince", id: 818323528755314698n }, + PandaNinjas: { + name: "PandaNinjas", + id: 455128749071925248n + }, CatNoir: { name: "CatNoir", id: 260371016348336128n |