diff options
author | Berlin <39058370+somerandomcloud@users.noreply.github.com> | 2022-10-10 01:35:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-10 01:35:50 +0200 |
commit | 124d1ad9c7138bce4c65325e2db47f615e463de6 (patch) | |
tree | c83231c2b6b4a2189d9ef04ae8ee85a65beb0c31 /src/plugins | |
parent | abfade4f38064e16c80e442a6b80d44aa1cac2ef (diff) | |
download | Vencord-124d1ad9c7138bce4c65325e2db47f615e463de6.tar.gz Vencord-124d1ad9c7138bce4c65325e2db47f615e463de6.tar.bz2 Vencord-124d1ad9c7138bce4c65325e2db47f615e463de6.zip |
Plugin that removes canary subdomain from message (#60)
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/noCanaryMessageLinks.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/plugins/noCanaryMessageLinks.ts b/src/plugins/noCanaryMessageLinks.ts new file mode 100644 index 0000000..c566c5e --- /dev/null +++ b/src/plugins/noCanaryMessageLinks.ts @@ -0,0 +1,21 @@ +import definePlugin from "../utils/types"; +import { addPreSendListener, MessageObject, removePreSendListener } from "../api/MessageEvents"; + +export default definePlugin({ + name: "NoCanaryMessageLinks", + description: "Removes the canary and ptb prefix from message links", + authors: [{ name: "ICodeInAssembly", id: 702973430449832038n }], + dependencies: ["MessageEventsAPI"], + + removeBetas(msg: MessageObject) { + msg.content = msg.content.replace(/(?<=https:\/\/)(canary.|ptb.)(?=discord(?:app)?.com\/channels\/(?:\d{17,20}|@me)\/\d{17,20}\/\d{17,20})/g, ""); // Ven W + }, + + start() { + this.preSend = addPreSendListener((_, msg) => this.removeBetas(msg)); + }, + + stop() { + removePreSendListener(this.preSend); + } +}); |