Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Sharding #211

Merged
merged 14 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,23 @@
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"name": "Launch Bot",
"skipFiles": [
"<node_internals>/**",
"**/q.js"
],
"program": "${workspaceFolder}\\bot.js"
},
{
"type": "node",
"request": "launch",
"name": "Launch Shards",
"skipFiles": [
"<node_internals>/**",
"**/q.js"
],
"program": "${workspaceFolder}\\index.js"
},
{
"type": "node",
"request": "launch",
Expand Down
4 changes: 2 additions & 2 deletions PRIVACY_POLICY.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ With the command `/conf` you can set the default `locale` and `game` for your Di

Typing a command will increment a counter and refresh the last use timestamp in our database. This is the only information that are saved.

The usage statistics are shared with our [Patreon](https://patreon.com/Stefouch) members and [Free League Publishing](https://frialigan.se).
The usage statistics are shared in the form of an annual report with our [Patreon](https://patreon.com/Stefouch) members and [Free League Publishing](https://frialigan.se).

## Questions

If you have any additional questions regarding this document, you can of course reach me on Twitter [@stefouch](https://twitter.com/stefouch) or in the public [Year Zero Worlds](https://discord.gg/RnaydHR) Discord server.
If you have any additional questions regarding this document, you can of course reach me `@stefouch` in the public [Year Zero Worlds](https://discord.gg/RnaydHR) Discord server.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: echo "No web process"
worker: node bot.js
worker: node index.js
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
<a href="https://www.patreon.com/Stefouch">
<img src="https://img.shields.io/badge/donate-patreon-F96854.svg" alt="Patreon">
</a>
<a href="https://twitter.com/stefouch" target="_blank">
<img alt="Twitter: stefouch" src="https://img.shields.io/twitter/follow/stefouch.svg?style=social"/>
</a>
</p>

> **Warning**: **Important Changes!**<br/>
Expand Down Expand Up @@ -89,7 +86,6 @@ Contributions, translations, issues and feature requests are welcome!<br/>Take a
### 👤 Stefouch

- **Github:** [@Stefouch](https://github.com/Stefouch)
- **Twitter:** [@stefouch](https://twitter.com/stefouch)
- **Discord:** Stefouch on [Year Zero Worlds](https://discord.gg/RnaydHR)

# ❤️ Sponsoring
Expand Down
2 changes: 2 additions & 0 deletions count-lines-of-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
find ./src -name '*.js' | xargs wc -l
20 changes: 20 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { ShardingManager } = require('discord.js');
const Logger = require('./src/utils/logger');
// const PRODUCTION = process.env.NODE_ENV === 'production';

// First, loads the ENV variables (e.g. bot's token).
// if not in production mode.
// if (!PRODUCTION) {
// require('dotenv').config();
// }

const manager = new ShardingManager('./bot.js', {
totalShards: 'auto',
// token: PRODUCTION ? process.env.DISCORD_TOKEN : process.env.BETA_DISCORD_TOKEN,
// execArgv: ['--trace-warnings'],
// shardArgs: ['--ansi', '--color'],
});

manager.on('shardCreate', shard => Logger.client(`🚀 Launched shard ${shard.id}`));

manager.spawn();
Loading
Loading