Skip to content

Commit dc2088f

Browse files
authored
[DISC-109] Adding bot-status for events and member count (#169)
* Adding bot-status for events and member count * Fixing lint errors * Adding fixes to how member count is calculated --------- Authored-by: Eric <[email protected]>
1 parent 6da7e8e commit dc2088f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

events/log_ready.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
const { DBlog } = require("../lib/database/dblog");
22

3+
let currentStatusIndex = 0;
4+
const CSESOC_SERVER_ID = "693779865916276746";
5+
const statusSeconds = 30;
6+
7+
// In case of events working
8+
// let currentEventIndex = 0;
9+
// const events = ["EVENT"];
10+
311
module.exports = {
412
name: "ready",
513
once: true,
@@ -23,5 +31,30 @@ module.exports = {
2331
}
2432
}
2533
})();
34+
35+
// Status change functions
36+
const statusFunctions = [
37+
() => memberCountStatus(client),
38+
// () => specialEventStatus(client, events[currentEventIndex]),
39+
];
40+
41+
setInterval(() => {
42+
statusFunctions[currentStatusIndex]();
43+
currentStatusIndex = (currentStatusIndex + 1) % statusFunctions.length;
44+
}, 1000 * statusSeconds);
2645
},
2746
};
47+
48+
function memberCountStatus(client) {
49+
const server = client.guilds.cache.get(CSESOC_SERVER_ID);
50+
if (!server) {
51+
return;
52+
}
53+
54+
client.user.setActivity(`${server.memberCount} members!`, { type: "LISTENING" });
55+
}
56+
57+
// function specialEventStatus(client, event) {
58+
// client.user.setActivity(event, { type: "COMPETING" });
59+
// currentEventIndex = (currentEventIndex + 1) % events.length;
60+
// }

0 commit comments

Comments
 (0)