mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-18 19:07:08 -04:00
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:
parent
b17b248f74
commit
8860ace4a5
1 changed files with 48 additions and 0 deletions
48
src/equicordplugins/ingtoninator/index.ts
Normal file
48
src/equicordplugins/ingtoninator/index.ts
Normal 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);
|
||||||
|
}
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue