Uwufy: Add option to uwufy all messages (#1036)
Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
parent
6bf6583e7d
commit
9d62dec6b9
2 changed files with 38 additions and 3 deletions
|
@ -17,8 +17,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { findOption, RequiredMessageOption } from "@api/Commands";
|
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 { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
|
||||||
const endings = [
|
const endings = [
|
||||||
"rawr x3",
|
"rawr x3",
|
||||||
|
@ -65,6 +67,15 @@ const replacements = [
|
||||||
["meow", "nya~"],
|
["meow", "nya~"],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const settings = definePluginSettings({
|
||||||
|
uwuEveryMessage: {
|
||||||
|
description: "Make every single message uwuified",
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
default: false,
|
||||||
|
restartNeeded: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function selectRandomElement(arr) {
|
function selectRandomElement(arr) {
|
||||||
// generate a random index based on the length of the array
|
// generate a random index based on the length of the array
|
||||||
const randomIndex = Math.floor(Math.random() * arr.length);
|
const randomIndex = Math.floor(Math.random() * arr.length);
|
||||||
|
@ -94,8 +105,9 @@ function uwuify(message: string): string {
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "UwUifier",
|
name: "UwUifier",
|
||||||
description: "Simply uwuify commands",
|
description: "Simply uwuify commands",
|
||||||
authors: [Devs.echo, Devs.skyevg],
|
authors: [Devs.echo, Devs.skyevg, Devs.PandaNinjas],
|
||||||
dependencies: ["CommandsAPI"],
|
dependencies: ["CommandsAPI", "MessageEventsAPI"],
|
||||||
|
settings,
|
||||||
|
|
||||||
commands: [
|
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);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -299,6 +299,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
name: "carince",
|
name: "carince",
|
||||||
id: 818323528755314698n
|
id: 818323528755314698n
|
||||||
},
|
},
|
||||||
|
PandaNinjas: {
|
||||||
|
name: "PandaNinjas",
|
||||||
|
id: 455128749071925248n
|
||||||
|
},
|
||||||
CatNoir: {
|
CatNoir: {
|
||||||
name: "CatNoir",
|
name: "CatNoir",
|
||||||
id: 260371016348336128n
|
id: 260371016348336128n
|
||||||
|
|
Loading…
Reference in a new issue