Skip to content

Commit

Permalink
rbl stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowLp174 committed Jun 1, 2023
1 parent 1087aeb commit 31ff200
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 880 deletions.
1 change: 1 addition & 0 deletions config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"password": "password of your user",
"database": "name of the target database"
},
"rbl": "Your token for revoltbots.org; optional",
"webPort": 80,
"ssl": {
"private": "path-to-private-key.pem",
Expand Down
22 changes: 22 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class Remix {
}, this.presenceInterval);
});

this.sendRblStats();
if (!this.config.fetchUsers) return;
this.fetchUsers();
setInterval(() => this.fetchUsers, 60 * 1000 * 30);
Expand Down Expand Up @@ -107,6 +108,9 @@ class Remix {
data.splice(idx, 1);
this.memberMap.set(member.id.server, data);
});
this.client.on("ServerserverCreate", () => {
if (this.config.rbl) this.sendRblStats();
});

console.log("Loading command files...");
this.handler = new CommandHandler(this.client, config.prefix);
Expand Down Expand Up @@ -202,6 +206,24 @@ class Remix {
static sleep(ms) {
return new Promise(res => setTimeout(res, ms));
}
sendRblStats() {
console.log("request");
require("https").request({
host: "revoltbots.org",
path: "/api/v1/bots/stats",
method: "POST",
headers: {
"server_count": this.client.servers.size(),
"Authorization": this.config.rbl
}
}, function(res) {
res.on("data", (d) => {
console.log(Buffer.from(d).toString());
});
}, function(err) {
console.log(err);
});
}
async fetchUsers() {
const promises = [];
for (const server of this.client.servers) {
Expand Down
Loading

0 comments on commit 31ff200

Please sign in to comment.