From 8860ace4a58977107a02b1a5cdb9909627d200d6 Mon Sep 17 00:00:00 2001 From: zyqunix <117040076+zyqunix@users.noreply.github.com> Date: Fri, 16 May 2025 21:39:45 +0200 Subject: [PATCH] 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> --- src/equicordplugins/ingtoninator/index.ts | 48 +++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/equicordplugins/ingtoninator/index.ts diff --git a/src/equicordplugins/ingtoninator/index.ts b/src/equicordplugins/ingtoninator/index.ts new file mode 100644 index 000000000..2b8a06f3d --- /dev/null +++ b/src/equicordplugins/ingtoninator/index.ts @@ -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); + } +});