Creating a Vencord plugin for Discord involves writing JavaScript code to interact with the Vencord API. Below is an example of how you could implement this plugin to convert letters in sent messages to specific words, with functionalities to enable/disable the plugin and translate messages from others.
// ==UserScript==
// @name Alphabet to Kitty Speak Converter
// @description Converts letters in messages to cute kitty words
// @version 1.0
// ==/UserScript==
(function() {
'use strict';
// Mapping of letters to kitty words
const kittySpeakMap = {
a: "meow", b: "meow nya", c: "purr", d: "mrow", e: "nyan",
f: "hiss", g: "mew", h: "nya", i: "miao", j: "nyaa",
k: "meow meow", l: "purrr", m: "miaow", n: "nyan nyan", o: "meoww",
p: "paw", q: "mrrp", r: "rrmeow", s: "sss", t: "trill",
u: "uwu", v: "nyav", w: "whisker", x: "mrrrow", y: "yowl", z: "zzz"
};
let pluginEnabled = true;
function translateToKittySpeak(message) {
return message.split('').map(char => {
const lowerChar = char.toLowerCase();
return kittySpeakMap[lowerChar] || char;
}).join(' ');
}
function onSendMessage(content) {
if (!pluginEnabled) return content;
return translateToKittySpeak(content);
}
function onMessageReceived(content) {
if (!pluginEnabled) return content;
return translateToKittySpeak(content);
}
function togglePlugin() {
pluginEnabled = !pluginEnabled;
alert(`Kitty Speak Plugin is now ${pluginEnabled ? 'enabled' : 'disabled'}`);
}
// Bind togglePlugin to some keyboard shortcut or UI button
VencordAPI.createCommand('togglekittyplugin', togglePlugin);
// Hook into Vencord send and receive message events
VencordAPI.on('messageSend', (message) => {
const modifiedContent = onSendMessage(message.content);
message.content = modifiedContent;
});
VencordAPI.on('messageReceive', (message) => {
const modifiedContent = onMessageReceived(message.content);
message.content = modifiedContent;
});
})();
Explanation:
-
Mapping Dictionary: A JavaScript object maps each letter in the alphabet to corresponding "kitty speak" words.
-
Translation Function: translateToKittySpeak converts a given message to "kitty speak."
-
Enable/Disable Functionality: A boolean, pluginEnabled, tracks the plugin's status. The togglePlugin function toggles this value and provides feedback via an alert.
-
Message Hooks: Hooks into the Vencord API's message send and receive events, applying translations when the plugin is enabled.
-
Toggle Command: The command togglekittyplugin is registered to toggle the plugin. You would set this up with a proper user command or button in a real scenario.
-
Integration with Vencord API: This example assumes you have access to the Vencord API, which supports these functions (createCommand, on for event handling). You need to check Vencord documentation for actual API availability and usage.
This script needs to be integrated into your Vencord environment and tested. Adjust the integration points according to your actual Vencord setup and API capabilities.