diff --git a/.gitignore b/.gitignore index 248948afcbd01cfabb553f55f725a400bc5d0a75..d4795b9e207b19e5d76951a6bd470b7fb587099c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -token .env node_modules -index.js +logs diff --git a/bot.ts b/bot.ts new file mode 100644 index 0000000000000000000000000000000000000000..734357275023d1055e271d42419a94a7174dedd9 --- /dev/null +++ b/bot.ts @@ -0,0 +1,8 @@ +const { ShardingManager } = require('discord.js'); + +const manager = new ShardingManager('./index.ts', { token: process.env.TOKEN }); + +manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`)); + +manager.spawn(); + diff --git a/index.ts b/index.ts index 9742b52b6e4dab243016883e720850e4a52e3d76..486528ca3461c087f388fb029d36b8de079d5e3f 100644 --- a/index.ts +++ b/index.ts @@ -13,10 +13,10 @@ Some things to note - Roles always are added at the bottom of the role list, meaning none of your other roles should have colors. To use me, simply run -> /paint +> \`/paint \` > Where is any valid HEX or CSS color value. -Created by dave caruso, , support \`me@paperdave.net\``; +Created by paper clover, , support \`namepaint@paperclover.net\``; const client = new Discord.Client({ intents: [ @@ -25,13 +25,14 @@ const client = new Discord.Client({ ], }); -function updateClientStatus() { - client.user?.setActivity(`/paint | ${client.guilds.cache.size} servers.`) +async function updateClientStatus() { + const totalGuilds = (await client.shard.fetchClientValues("guilds.cache.size")).reduce((a, b) => a + b); + client.user?.setActivity(`/paint | ${totalGuilds} servers.`) } client.on('ready', async() => { console.log(`Logged in as ${client.user?.tag}!`); - updateClientStatus(); + updateClientStatus().catch((err) => { console.error(err); }); // client.application.commands.create({ // name: 'paint', @@ -157,7 +158,7 @@ client.on('guildMemberRemove', (member) => { }); client.on('guildDelete', guild => { - updateClientStatus(); + updateClientStatus().catch(err => console.error(err)); }); async function getDefaultChannel(guild: Discord.Guild) { @@ -184,7 +185,7 @@ client.on('guildCreate', async(guild) => { let defaultChannel = await getDefaultChannel(guild) as Discord.TextChannel; defaultChannel && defaultChannel.send(helpMessage); - updateClientStatus(); + updateClientStatus().catch(err => console.error(err)); }); client.login(process.env.TOKEN);