Sure! Below is a Vencord plugin that automatically converts letters in messages to the specified cat words. It includes functionality to enable/disable the plugin and to translate incoming messages from others.
typescript
// CatifyPlugin.ts
import { Plugin } from "vencord";
import { registerPlugin } from "vencord/plugin";
import { after } from "vencord/patcher";
import { webpack } from "vencord/webpack";
import { React } from "vencord/webpack/common";
const catWords: Record<string, string> = {
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",
};
const CatifyPlugin: Plugin = {
name: "Catify Plugin",
description: "Automatically converts letters in messages to cat words.",
version: "1.0.0",
author: "YourName", // Replace with your name
settings: {
enabled: true,
translateIncoming: false,
},
async start() {
// Hook into the message sending function to modify outgoing messages
const MessageSender = webpack.findByProps("sendMessage");
this.unpatchSendMessage = after("sendMessage", MessageSender, ([channelId, message]) => {
if (!this.settings.enabled) return;
message.content = translateMessage(message.content);
});
// Hook into the message rendering to modify incoming messages
const MessageContent = webpack.find(
(m) => m?.type?.toString().includes("messageContent")
);
this.unpatchMessageContent = after("type", MessageContent, ([props], res) => {
if (!this.settings.enabled || !this.settings.translateIncoming) return res;
if (!props?.children?.props?.content) return res;
const originalContent = props.children.props.content;
props.children.props = { ...props.children.props };
props.children.props.content = translateMessage(originalContent);
return res;
});
},
stop() {
// Unpatch the functions when the plugin is disabled
this.unpatchSendMessage();
this.unpatchMessageContent();
},
// Settings panel to enable/disable the plugin and incoming message translation
settingsPanel: ({ settings }) => {
return (
<div>
<label>
<input
type="checkbox"
checked={settings.enabled}
onChange={() => (settings.enabled = !settings.enabled)}
/>
Enable Catify Plugin
</label>
<br />
<label>
<input
type="checkbox"
checked={settings.translateIncoming}
onChange={() => (settings.translateIncoming = !settings.translateIncoming)}
/>
Translate Incoming Messages
</label>
</div>
);
},
};
// Function to translate a message's content
function translateMessage(content: string): string {
return content
.split("")
.map((char) => {
const lowerChar = char.toLowerCase();
return catWords[lowerChar] || char;
})
.join(" ");
}
registerPlugin(CatifyPlugin);
Explanation:
Translation Logic: The translateMessage function takes the message content and replaces each letter with the corresponding cat word from the provided catWords mapping.
Outgoing Messages: The plugin patches the sendMessage function to modify outgoing messages before they are sent.
Incoming Messages: If enabled in settings, the plugin also patches the message rendering component to modify incoming messages.
Settings Panel: Provides an interface to enable/disable the plugin and the translation of incoming messages.
Instructions to Use:
Create a New Plugin File:
Save the above code into a file named CatifyPlugin.ts (or CatifyPlugin.js if not using TypeScript).
Add the Plugin to Vencord:
Place the plugin file into your Vencord plugins directory.
Alternatively, you can load the plugin via the Vencord UI if it supports loading custom plugins.
Enable the Plugin:
Open Vencord's plugin settings and enable the "Catify Plugin".
Adjust the settings to your preference (enable/disable incoming message translation).
Test the Plugin:
Send a message to see it transformed.
View incoming messages (if enabled) to see them transformed.
Note:
Ensure that the plugin complies with Vencord's plugin API and the specific version you are using.
You might need to adjust the module finders (webpack.findByProps, etc.) based on the actual implementation in Vencord.
Replace "YourName" with your actual name or handle in the plugin metadata.
Disclaimer:
This plugin is intended for fun and educational purposes. Modifying messages in Discord may violate Discord's terms of service. Use at your own risk and ensure compliance with all relevant policies.