Certainly! Below is a Vencord plugin named CatTranslator that automatically converts each letter in sent and received messages to predefined cat-themed words. The plugin includes functionality to enable or disable the translation feature.
CatTranslator Plugin
// Meta Information
/**
* @name CatTranslator
* @version 1.0.0
* @description Automatically converts each letter in messages to cat-themed words.
* @author YourName
* @discord https://discord.gg/yourdiscord
*/
module.exports = (() => {
const catWords = {
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"
};
// Utility function to translate a single message
function translateMessage(message, isOutgoing) {
return message.split('').map(char => {
const lowerChar = char.toLowerCase();
if (catWords[lowerChar]) {
// Preserve original casing
return char === lowerChar ? catWords[lowerChar] : capitalize(catWords[lowerChar]);
} else {
return char;
}
}).join(' ');
}
// Capitalize first letter
function capitalize(text) {
return text.charAt(0).toUpperCase() + text.slice(1);
}
// Plugin Class
class CatTranslator {
constructor() {
this.enabled = true; // Plugin is enabled by default
}
getName() { return "CatTranslator"; }
getDescription() { return "Automatically converts each letter in messages to cat-themed words."; }
getVersion() { return "1.0.0"; }
getAuthor() { return "YourName"; }
// Method to start the plugin
start() {
// Inject CSS if needed (not required here)
// Override the send message function
const messageStore = BdApi.findModuleByProps("sendMessage");
if (messageStore && messageStore.sendMessage) {
this.originalSendMessage = messageStore.sendMessage;
messageStore.sendMessage = (channelId, messageContent, options) => {
if (this.enabled) {
const translated = translateMessage(messageContent, true);
return this.originalSendMessage(channelId, translated, options);
}
return this.originalSendMessage(channelId, messageContent, options);
};
}
// Listen to incoming messages and translate them
const MessageActions = BdApi.findModuleByProps("sendMessage", "deleteMessage");
if (MessageActions) {
this.messageListener = (message) => {
if (message && message.content && this.enabled) {
const translatedContent = translateMessage(message.content, false);
if (translatedContent !== message.content) {
// Use MutationObserver or similar to replace text if necessary
// This is a simplified approach and may need enhancements
message.content = translatedContent;
}
}
};
BdApi.Patcher.after("CatTranslator", MessageActions, "sendMessage", (_, args, ret) => {
const [channelId, messageContent] = args;
this.messageListener({ content: messageContent });
});
}
// Add a toggle command or UI
this.addToggleCommand();
}
// Method to stop the plugin
stop() {
// Restore original sendMessage function
const messageStore = BdApi.findModuleByProps("sendMessage");
if (messageStore && this.originalSendMessage) {
messageStore.sendMessage = this.originalSendMessage;
}
// Remove message listener
if (this.messageListener) {
// Implementation to remove the listener
}
// Remove toggle command or UI
this.removeToggleCommand();
}
// Method to add a toggle command
addToggleCommand() {
const Dispatcher = BdApi.findModuleByProps("dispatch", "subscribe");
if (Dispatcher) {
this.dispatcher = Dispatcher;
this.toggleCommand = () => {
this.enabled = !this.enabled;
BdApi.showToast(`CatTranslator ${this.enabled ? "Enabled" : "Disabled"}`, { type: 'success' });
};
// This is a placeholder. Implement a proper command registration if supported.
window.addEventListener('keydown', (e) => {
if (e.ctrlKey && e.shiftKey && e.key === 'C') { // Example shortcut: Ctrl+Shift+C
this.toggleCommand();
}
});
}
}
// Method to remove the toggle command
removeToggleCommand() {
if (this.dispatcher) {
// Implementation to remove the listener
}
window.removeEventListener('keydown', this.toggleCommand);
}
}
return new CatTranslator();
})();
Installation Guide
-
Ensure Vencord is Installed:
-
Create the Plugin File:
- Navigate to your Vencord plugins directory. This is typically located at:
- Windows:
%appdata%/vencord/plugins
- macOS:
~/Library/Application Support/vencord/plugins
- Linux:
~/.vencord/plugins
- Create a new file named
CatTranslator.plugin.js.
-
Paste the Plugin Code:
- Open
CatTranslator.plugin.js with a text editor and paste the plugin code provided above.
-
Save the File:
- Ensure the file is saved with the
.plugin.js extension.
-
Enable the Plugin:
- Open Discord.
- Go to
User Settings (the gear icon).
- Navigate to
Vencord > Plugins.
- Locate
CatTranslator in the list and toggle it on.
-
Using the Toggle Functionality:
- By default, the plugin is enabled.
- To toggle the plugin on or off, use the keyboard shortcut Ctrl + Shift + C.
- A toast notification will appear indicating whether the plugin is enabled or disabled.
Notes and Considerations
Feel free to customize and enhance the plugin to better suit your needs! If you have any questions or need further assistance, let me know.