forked from Metalloriff/BetterDiscordPlugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GuildAndFriendRemovalAlerts.plugin.js
62 lines (55 loc) · 2.49 KB
/
GuildAndFriendRemovalAlerts.plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* @name GuildAndFriendRemovalAlerts
* @invite yNqzuJa
* @authorLink https://github.com/Metalloriff
* @donate https://www.paypal.me/israelboone
* @website https://metalloriff.github.io/toms-discord-stuff/
* @source https://github.com/Metalloriff/BetterDiscordPlugins/blob/master/GuildAndFriendRemovalAlerts.plugin.js
*/
const name = "GuildAndFriendRemovalAlerts";
const newUrl = "https://github.com/Metalloriff/BetterDiscordPlugins/tree/master/" + name;
const rawUrl = `https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/${name}/${name}.plugin.js`;
module.exports = (() => {
const config = {
info: {
name: "0 GuildAndFriendRemovalAlerts OUTDATED",
authors: [{
name: "Metalloriff",
discord_id: "264163473179672576",
github_username: "metalloriff",
twitter_username: "Metalloriff"
}],
version: "999.999.999",
description: `Please delete this plugin and download the new one at ${newUrl}.`
}
};
return class {
getName = () => config.info.name;
getAuthor = () => config.info.authors[0].name;
getDescription = () => config.info.description;
getVersion = () => config.info.version;
load() {
BdApi.showConfirmationModal("Outdated Plugin", `This version of ${name} is outdated, consider installing the newest one by clicking the "Update Now" button.`, {
onConfirm: () => {
const https = require("https");
const fs = require("fs");
const path = require("path");
https.get(rawUrl, res => {
const chunks = [];
res.on("data", chunk => chunks.push(chunk));
res.on("end", () => {
try {
fs.writeFileSync(path.resolve(BdApi.Plugins.folder, path.basename(rawUrl)), chunks.join(""), "utf8");
} catch (error) {
console.error(name, error);
BdApi.showToast("Failed to download new update - check the console for details", { type: "error" });
}
});
});
}
});
}
start() { }
stop() { }
};
})();