add Ingtoninator plugin (#261)

* Add a morse code plugin to trans to/from morse code

* comment

* Update index.ts

* add plugington

* make it not do links.. found this out the hard wayington

* another update

* update

* Some Fixes

---------

Co-authored-by: thororen <78185467+thororen1234@users.noreply.github.com>
This commit is contained in:
zyqunix 2025-05-16 21:39:45 +02:00 committed by GitHub
parent b17b248f74
commit 8860ace4a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,48 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { addMessagePreSendListener, MessageSendListener, removeMessagePreSendListener } from "@api/MessageEvents";
import { EquicordDevs } from "@utils/constants";
import definePlugin from "@utils/types";
const isLegal = (word: string) => {
if (word.startsWith("<@")) return false;
if (/^https?:\/\//i.test(word)) return false;
return true;
};
const handleMessage: MessageSendListener = (channelId, message) => {
if (!message.content || !message.content.trim()) return;
const words = message.content.trim().split(/\s+/);
if (words.length === 0) return;
let index = -1;
let attempts = 0;
do {
index = Math.floor(Math.random() * words.length);
attempts++;
} while (!isLegal(words[index]) && attempts < words.length * 2);
if (isLegal(words[index])) {
const word = words[index];
words[index] = word === word.toUpperCase() ? word + "INGTON" : word + "ington";
}
message.content = words.join(" ");
};
export default definePlugin({
name: "Ingtoninator",
description: "Suffixes 'ington' to a random word in your message",
authors: [EquicordDevs.zyqunix],
start() {
addMessagePreSendListener(handleMessage);
},
stop() {
removeMessagePreSendListener(handleMessage);
}
});