authorgravatar for git@paperclover.netclover caruso <git@paperclover.net> 2025-07-21 15:11:58+00:00
committergravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-01-02 23:03:56-08:00
logd72cf6bf1abbad5f4d313a7958fb576c14120580
treea7c5a8fcff73f791c81d4e90b3603021c5492df4
parentd5b9fe35cbd392605253db8e85926f3096472b1b
signaturelock-open Commit is signed but in an unrecognized format.

add sharding support as name paint is in 2527 servers


3 files changed, 17 insertions(+), 9 deletions(-)

.gitignore+1-2
...@@ -1,4 +1,3 @@...@@ -1,4 +1,3 @@
1token
2.env1.env
3node_modules2node_modules
4index.js3logs
bot.ts created+8
...@@ -0,0 +1,8 @@
1const { ShardingManager } = require('discord.js');
2
3const manager = new ShardingManager('./index.ts', { token: process.env.TOKEN });
4
5manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));
6
7manager.spawn();
8
index.ts+8-7
...@@ -13,10 +13,10 @@ Some things to note...@@ -13,10 +13,10 @@ Some things to note
13- Roles always are added at the bottom of the role list, meaning none of your other roles should have colors.13- Roles always are added at the bottom of the role list, meaning none of your other roles should have colors.
1414
15To use me, simply run15To use me, simply run
16> /paint <color>16> \`/paint <color>\`
17> Where <color> is any valid HEX or CSS color value.17> Where <color> is any valid HEX or CSS color value.
1818
19Created by dave caruso, <https://paperdave.net>, support \`me@paperdave.net\``;19Created by paper clover, <https://paperclover.net>, support \`namepaint@paperclover.net\``;
2020
21const client = new Discord.Client({21const client = new Discord.Client({
22 intents: [22 intents: [
...@@ -25,13 +25,14 @@ const client = new Discord.Client({...@@ -25,13 +25,14 @@ const client = new Discord.Client({
25 ],25 ],
26});26});
2727
28function updateClientStatus() {28async function updateClientStatus() {
29 client.user?.setActivity(`/paint | ${client.guilds.cache.size} servers.`)29 const totalGuilds = (await client.shard.fetchClientValues("guilds.cache.size")).reduce((a, b) => a + b);
30 client.user?.setActivity(`/paint | ${totalGuilds} servers.`)
30}31}
3132
32client.on('ready', async() => {33client.on('ready', async() => {
33 console.log(`Logged in as ${client.user?.tag}!`);34 console.log(`Logged in as ${client.user?.tag}!`);
34 updateClientStatus();35 updateClientStatus().catch((err) => { console.error(err); });
3536
36 // client.application.commands.create({37 // client.application.commands.create({
37 // name: 'paint',38 // name: 'paint',
...@@ -157,7 +158,7 @@ client.on('guildMemberRemove', (member) => {...@@ -157,7 +158,7 @@ client.on('guildMemberRemove', (member) => {
157});158});
158159
159client.on('guildDelete', guild => {160client.on('guildDelete', guild => {
160 updateClientStatus();161 updateClientStatus().catch(err => console.error(err));
161});162});
162163
163async function getDefaultChannel(guild: Discord.Guild) {164async function getDefaultChannel(guild: Discord.Guild) {
...@@ -184,7 +185,7 @@ client.on('guildCreate', async(guild) => {...@@ -184,7 +185,7 @@ client.on('guildCreate', async(guild) => {
184 let defaultChannel = await getDefaultChannel(guild) as Discord.TextChannel;185 let defaultChannel = await getDefaultChannel(guild) as Discord.TextChannel;
185 defaultChannel && defaultChannel.send(helpMessage);186 defaultChannel && defaultChannel.send(helpMessage);
186187
187 updateClientStatus();188 updateClientStatus().catch(err => console.error(err));
188});189});
189190
190client.login(process.env.TOKEN);191client.login(process.env.TOKEN);