Under development
A discord bot that tracks submissions for Black Flag Academy's weekly challenges. Includes an admin interface for admin things. Makes heavy use of discord.py and Django.
!help
- shows available commands
!submit <score> {attached photo}
- Submit a score with picture for the BFA Weekly Challenge. This command requires a photo attachment to be part of the message.
!addtwitter <twitter>
- Add twitter username to Student profile
!addname <ddr_name>
- Add DDR name (ex. KEEKSTER) to Student profile
!newweek <challenge name>
- Start a new weekly challenge
!close
- Prevent submissions for the current challenge
!reopen
- Resume submissions for the current challenge
This app is hosted on heroku at https://bfa-submissions.herokuapp.com/. Changes merged to the main branch are automatically deployed.
These can all be set via the Heroku settings dashboard for this app or using the heroku config:set
cli command.
SECRET_KEY
: Randomly generated Django secret keyDISCORD_BOT_TOKEN
: Token for the Discord bot (for instructions on creating one, see the discord.py docsSUBMISSION_CHANNEL_ID
: Discord channel ID for the submissions channel
From the app's heroku dashboard:
- Click "More" >> "Run console"
- Enter
python manage.py createsuperuser
- From there you will be prompted to enter a username, email, and password.
- (If you're creating an account for someone else, enter a temporary password that you can send to them later. They'll be able to change this password once they login.)
Alternatively, if you have the heroku-cli installed, you can run this from your terminal instead:
heroku run -a bfa-submissions python manage.py createsuperuser
Instructions to run this from your local computer.
Requires Python >= 3.6 and PostgreSQL
-
Clone the repo to your computer
-
Create and activate your virtual environment
-
Install dependencies
python -m pip install -r requirements.txt
-
Create database
createdb bfa
-
Run database migrations
python manage.py migrate
-
Create a local superuser (you'll use these fake creds to log in to the admin site locally)
python manage.py createsuperuser
-
Copy secrets.sample to secrets.sh
cp secrets.sample secrets.sh
-
Create and invite a bot account to your server
- Follow these instructions: https://discordpy.readthedocs.io/en/stable/discord.html
- Replace
faketoken
in secrets.sh with your bot's token - The bot will need the following permissions when you invite it to your Discord:
- View channels
- Send messages
- Read message history
- Add reactions
-
Get the ID for the specific channel you want the bot to work in
- Right-click the channel name and select "Copy ID"
- Replace
12345
in secrets.sh with your channel id
- (Activate your virtual environment)
-
source secrets.sh && python manage.py runserver
- Go to
localhost:8000
in your browser
- (Activate your virtual environment)
-
source secrets.sh && python bot.py
-
SECRET_KEY=abc pytest
bot stuff:
- initial bot setup
- add things to db on submission
- bot testing
- bot resume/catchup after off/on
- auto determine student level (freshman, etc) by discord role
web stuff:
- figure out django lol
- implement auth req'd
- view all submissions
- view by week + role/level
- view by user (in week?) (auto sort by latest or highest submission)
- leaderboard view (https://docs.djangoproject.com/en/3.2/ref/contrib/admin/#adding-views-to-admin-sites)
later:
- discord commands to close/open submissions (restricted to faculty role)
- discord command to change week (restricted to faculty role)
- command to let students add/change their dancer name or twitter info
-
python manage.py check --deploy
to look for things to change before actually hosting it - host on heroku
- discord oauth for front end login? :thinkingface:
- if the bot told you what your upscore was (if you’re replacing one) like +[x] in green
- add reaction & reply to messages in response
refactoring / legibility
- move helpers in models.py to helpers.py or something?
- use discord Cogs to group commands by role requirements
- better logging
- use logging instead of print?
- log before each command: https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.before_invoke
- slash commands?? https://discord-py-slash-command.readthedocs.io/en/latest/