Skip to content

Commit 17e5032

Browse files
committed
feat: add ready event
1 parent 471bf0d commit 17e5032

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

bot/events/ready.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ActivityType, Events, PresenceUpdateStatus } from 'discord.js';
2+
import client from '../index';
3+
4+
// update the bot's presence
5+
function updatePresence() {
6+
if (!client?.user) return;
7+
client.user.setPresence({
8+
activities: [
9+
{
10+
name: `${client.guilds.cache.size} servers with ${client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0).toLocaleString('en-US')} members.`,
11+
type: ActivityType.Watching,
12+
},
13+
],
14+
status: PresenceUpdateStatus.Online,
15+
});
16+
}
17+
18+
// Log into the bot
19+
client.once(Events.ClientReady, async (bot) => {
20+
console.log(`Ready! Logged in as ${bot.user?.tag}`);
21+
updatePresence();
22+
});
23+
24+
// Update the server count in the status every minute
25+
setInterval(updatePresence, 60000);

bun.lockb

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)