Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andreia-oca/discord_bot_template
A discord bot template written in nodejs
https://github.com/andreia-oca/discord_bot_template
discord discord-bot genezio nodejs qstash queue serverless
Last synced: 3 days ago
JSON representation
A discord bot template written in nodejs
- Host: GitHub
- URL: https://github.com/andreia-oca/discord_bot_template
- Owner: andreia-oca
- Created: 2023-09-01T12:52:52.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-22T14:20:28.000Z (11 months ago)
- Last Synced: 2024-04-24T07:50:28.634Z (7 months ago)
- Topics: discord, discord-bot, genezio, nodejs, qstash, queue, serverless
- Language: TypeScript
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Discord Bot template
This is a starter project for building discord bots.
Features:
- API to handle registering/unregistering discord commands
- queue support for long running tasks
- deployed to a serverless infrastructure
- implements the discord verification flow to correctly register a bot webhook
- lightweight codebase - written in typescript using Discord webhooks which makes the code very simple and easy to understandI am especially proud of this template because it runs long running tasks such as OpenAI calls in the background using a queue system. This enables the bot to be run on a serverless infrastructure, which is very cheap and easy to scale.
## Deploy it
This discord bot is deployed with `genezio` because it's easy to use and it has a generous free tier plan.
Genezio deploys to a serverless infrastructure, so I don't have to worry about scaling or managing servers.Deploy the bot by running the following command:
```
cd ./server && genezio deploy
```To have queue support, go to https://app.genez.io/, select your project and enable the QStash Queue integration.
Also, you need to set the following environment variables in the corresponding project page:
```
# Get them from https://discord.com/developers/applications
DISCORD_TOKEN=
DISCORD_APPLICATION_ID=
DISCORD_PUBLIC_KEY=# Get it from https://app.genez.io or from your terminal after deploying
QUEUE_WEBHOOK_URL=
```Your discord bot is now deployed and ready to use! Head to the Discord Developer Portal to copy the bot invite URL and add it to your server.
You can use the testing dashboard from app.genez.io to register/unregister commands for your bot.
## Fork it
I encourage you to fork this template and build your own discord bot on top of it.
I strongly believe this is a great starter that, essentially, costs you nothing to use and you can do pretty great things starting from here.
## Test it locally
You can also test the bot locally by using a proxy server such as [ngrok](https://ngrok.com/).
Start the local server by running:
```
genezio local
```Then, expose the local webhook with ngrok by running:
```
ngrok http 8083
```Use the URL generated by ngrok to register the webhook in the Discord Developer Portal and as an environment variable in the Genezio project page.
## Help
If you need any help running the bot, feel free to drop an [issue](https://github.com/andreia-oca/discord_bot_template/issues).
Also, I am excited to improve this template, so feel free to open an [issue(https://github.com/andreia-oca/discord_bot_template/issues)] with feature requests or a PR to contribute to it.
## Future work
- Add an admin dashboard to manage the bot commands
- Add analytics to track bot usage
- Integrate it with Reddit, Twitter, GitHub etc. to publish content to a Discord server## Resources
- Discord Developer Portal: [https://discord.com/developers/applications](https://discord.com/developers/applications)
- Genezio Webhook Documentation: [https://docs.genez.io/genezio-documentation/webhooks](https://docs.genez.io/genezio-documentation/webhooks)