Plugin

RelationshipNotifier

Notifies you when a friend, group chat, or server removes you.

Friends Notifications
index.ts
Download

Source

src/plugins/relationshipNotifier/index.ts
1import { Devs } from "@utils/constants";
2import definePlugin from "@utils/types";
3
4import { onChannelDelete, onGuildDelete, onRelationshipRemove, removeFriend, removeGroup, removeGuild } from "./functions";
5import settings from "./settings";
6import { syncAndRunChecks, syncFriends, syncGroups, syncGuilds } from "./utils";
7
8export default definePlugin({
9 name: "RelationshipNotifier",
10 description: "Notifies you when a friend, group chat, or server removes you.",
11 tags: ["Friends", "Notifications"],
12 authors: [Devs.nick],
13 settings,
14
15 patches: [
16 {
17 find: "removeRelationship:(",
18 replacement: {
19 match: /(removeRelationship:\((\i),\i,\i\)=>)/,
20 replace: "$1($self.removeFriend($2),0)||"
21 }
22 },
23 {
24 find: "async leaveGuild(",
25 replacement: {
26 match: /(leaveGuild\((\i)\){)/,
27 replace: "$1$self.removeGuild($2);"
28 }
29 },
30 {
31 find: "},closePrivateChannel(",
32 replacement: {
33 match: /(closePrivateChannel\((\i)\){)/,
34 replace: "$1$self.removeGroup($2);"
35 }
36 }
37 ],
38
39 flux: {
40 GUILD_CREATE: syncGuilds,
41 GUILD_DELETE: onGuildDelete,
42 CHANNEL_CREATE: syncGroups,
43 CHANNEL_DELETE: onChannelDelete,
44 RELATIONSHIP_ADD: syncFriends,
45 RELATIONSHIP_UPDATE: syncFriends,
46 RELATIONSHIP_REMOVE(e) {
47 onRelationshipRemove(e);
48 syncFriends();
49 },
50 CONNECTION_OPEN: syncAndRunChecks
51 },
52
53 async start() {
54 setTimeout(() => {
55 syncAndRunChecks();
56 }, 5000);
57 },
58
59 removeFriend,
60 removeGroup,
61 removeGuild
62});
63