An awesome Discord Bot to integrate into virtual hackathons!
Report Bug
·
Request Feature
Because of COVID-19, many activities, including Hackathons, are being forced to move online. However, organizing virtual hackathons is unfamiliar territory to most. I wanted to create a Discord bot that provides much needed functionality to run a successful virtual hackathon.
Of course, every virtual hackathon has its own set of needs, so I'll be adding more features over time. You may also suggest changes by forking this repo and creating a pull request or opening an issue.
A list of commonly used resources that I find helpful are listed in the acknowledgements.
This will be split into two sections:
- Setting up your own bot to start writing code
- Deploying this bot on your server
This is an example of how to list things you need to use the software and how to install them.
- Python
- Discord.py
pip install -U discord.py
- Dotenv
pip install -U python-dotenv
Note: If you are using PyCharm, you can install these directly into your project's virtual environment throught 'File > Settings > Project > Python Interpreter > Install' and choose the specified libraries.
Then, set up a Discord Account and Test Server if you haven't already. This will allow you to gain access to the Developer Portal . Under 'Applications > Settings > OAuth2' give your bot the appropriate permissions. If you don't know what permissions to choose, just check 'Scopes > Bot' and 'Bot Permissions > General Permissions > Administrator' for now. In a new tab, open the generated link under 'Scopes' and choose your test server.
Now your bot is all set up, it is time to start coding. To start, you will need the following two files:
- Bot.py - This is just a starting template to familiarize you with some basic syntax
import os
from dotenv import load_dotenv
from discord.ext import commands
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
bot = commands.Bot(command_prefix='!')
@bot.event
async def on_ready():
print(f'{bot.user.name} has connected to Discord!')
@bot.command(name='roll_dice', help='Simulates rolling dice.')
async def roll(ctx, number_of_dice, number_of_sides):
dice = [
str(random.choice(range(1, number_of_sides + 1)))
for _ in range(number_of_dice)
]
await ctx.send(', '.join(dice))
bot.run(TOKEN)
- .env - This file will contain your bot key and other hidden data later on
DISCORD_TOKEN={your-bot-token}
DISCORD_GUILD={your-server-name}
The bot token can be found in the Developer Portal under 'Applications > Settings > Bot > Token'. Don't give this token to anyone else.
Now, you can start editing Bot.py and be able to use your bot within the server!
If you would like to run the code already in this repository, simply clone the repository, rename 'dummyenv.txt' to '.env' and change the variables in it, and then enter this in the command line:
python bot.py
This section will be written very soon!
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- 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.
Jason Math - jasonmath@utexas.edu