An awesome open source project to demonstrate usage of discord http interactions in python!
·
Report Bug
·
Request Feature
This repository is an open source project to demonstrate the usage of discord http interactions in python. There are many repos using discord gateway system to create bots, but this repo is different. This repo uses discord http interactions to create a bot. This is a very undiscovered feature of discord and is still underrated. This repo is created to demonstrate the usage of this feature.
Here's why:
- There's no repo on github that demonstrates the usage of discord http interactions in python.
- Everything in this repo is well documented and explained.
- This repo is open source and free to use.
- This repo is created to help people who are new to discord bots and want to learn how to create one.
- Http interactions can be used to host serverless bots, it saves us a lot of hosting resources and money.
A great example is Dyno bot on discord which is using gateway and http interactions both simontaneously to save hosting resources and money. You can do the same, just with some knowledge of python, discord http interactions and some creativity.
Of course, no one will serve all projects since your needs may be different. So I'll be adding more in the near future. You may also suggest changes by forking this repo and creating a pull request or opening an issue. Thanks to all the people have contributed to expanding this project!
- Clone this repo on your local machine
git clone https://github.com/Binacy/discord-http-interaction-bot
- Install the requirements (Sorry i use reqs instead of requirements)
pip3 install -U -r reqs.txt
- Create a discord application and bot on Discord Developer Portal
- Rename the example.env file to .env
- Complete the .env file with your bot token, application id and public key from the discord developer portal.
- Edit commands in commands.py
- Note: You will have to run upsert.py before main.py to upload your slash commands to discord.
- Run the bot
python3 main.py
- Sorry, you are not done yet! you have to use a server like ngrok to start a local webserver.
- Please install any server like ngrok and start a local webserver on port 3000.
ngrok http 3000
- Copy the https url from the ngrok terminal and paste it in the discord developer portal in the interaction section.
- You are done! Now you can use your bot in any server you want.
- Ah! not done yet, You can use web services like vercel to host your bot 24/7 for free. You can also use heroku.
- This is serverless hosting so it wont cost you much 😉
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Discord - @Binacy
Special thanks to Aditya and Amey for helping me with this project.