Vencord/src/plugins/fxTwitter.ts
Berlin 54198b1a4a
fxTwitter (plugin) (#80)
Co-authored-by: splatterxl <splatterxl@outlook.ie>
Co-authored-by: Ven <vendicated@riseup.net>
2022-10-10 22:45:54 +02:00

23 lines
695 B
TypeScript

import definePlugin from "../utils/types";
import { addPreSendListener, MessageObject, removePreSendListener } from "../api/MessageEvents";
import { Devs } from "../utils/constants";
export default definePlugin({
name: "FxTwitter",
description: "Uses FxTwitter to improve embeds from twitter on send",
authors: [Devs.Samu],
dependencies: ["MessageEventsAPI"],
addPrefix(msg: MessageObject) {
msg.content = msg.content.replace(/https?:\/\/twitter\.com(?=\/.*?\/)/g, "https://fxtwitter.com");
},
start() {
this.preSend = addPreSendListener((_, msg) => this.addPrefix(msg));
},
stop() {
removePreSendListener(this.preSend);
}
});