A discord bot for creating/managing cases
- Download the repository (
git clone https://github.com/TrevorBagels/CaseManager.git
) - Navigate to the directory (
cd CaseManager
) - Install dependencies (
pip3 install -r requirements.txt
) - Create a bot
- Go to the discord developer portal
- Click "Create a New Application"
- Go to the bot tab, click "Add Bot"
- Go to the "OAuth2" tab, click the "bot" checkbox
- Give the bot administrator permissions (might not be necessary, but some channel permission stuff doesn't seem to work very well without it.
- Copy the link that shows up above "BOT PERMISSIONS" and go to it. Use this to add it to your server.
- Copy the bot's token (Bot tab -> "TOKEN" area -> click "Copy"
- Configure
- In
./dev/
, create a new file called "config.json". Make the content of that file look like this:
{ "token": "ODE5Mjk2OTI0Nzk5NzI5NzQ1.YEkjuA.VyZaIT9TkTlv2xids-XpnMrHU7A", "gdrive": true, "parent_folder_id": "id_goes_here" }
- Replace the long string with the token you copied.
- In
- Set up google drive
- Go to the google developer console
- Create a project, call it whatever you want
- Click enable APIs and services after you wait a long time for stuff to load
- Search for "google drive api", click "google drive api"
- Click enable, wait forever for more stuff to load
- Click "credentials" (on the left sidebar), if it tries to take you to a credentials wizard, click it again
- Click "CREATE CREDENTIALS" (near the top left), select the OAuth one, then click "configure consent screen" when it asks you to do that.
- Select external, go to the next page
- Fill out all the required fields, go to the next page
- Skip the scopes page
- Add your email as a test user, hit "save and continue"
- Go back to the credentials tab
- Click create credentials, OAuth client ID
- Set application type to desktop app
- Save and continue
- Click the download button when you're taken back to the credentials tab. Save the file as
client_secrets.json
in./dev/
- Create a folder in google drive. Call it something like "Cases". Navigate to that folder, and copy it's ID. You can get the ID from the link to the folder, it usually looks like this:
https://drive.google.com/drive/u/7/folders/
reallyLongFileID
. Go back toconfig.json
and set theparent_folder_id
property to the ID you just copied.
Great, now run the bot cd ./dev
& python3 -m program
When running, go to the link that is prompted, and sign into the google account you're using with the Google Drive API. It'll tell you to copy a code and paste it into the console. Do that, press enter, and the bot should work now.
When the bot first starts up, you won't have any permissions to do anything with it. Give yourself the "case manager role" that is automatically generated when initializing the bot for the first time. This will give you full access to the bot. You can add permissions to other roles using ?perm @role [permission]
. Valid permissions are: none
, use
, create
, and manage
. use
gives access to the basic usage of the bot. create
lets people with the role create cases with ?create [case name]
. manage
is the highest permission, it lets people manage everything related to the bot.
The bot will also create three categories, one for active cases, one for archived cases, and one for division channels.
Use ?setemail [email_address]
to set your email address. Cases that you are a part of will automatically share their folders with you.
Use ?create [case name]
to create a case. You must have the create
permission or higher to be able to do this. A new case will be generated, along with a google drive folder and a discord channel.
In the channel for the case, use ?add [@member]
to add a member to the case.
To allow members to join the case voluntarily, set the security of the case to open
using ?security open
. To set it back to invite-only, set the security to strict
. Members must have the use
permission or higher to add themselves to a case. Members can add themselves via ?join [case_ID]
In the channel for the case, use ?close
to close and archive the case. Use ?reopen
to open it again.
Use ?transfer [@new_owner]
to transfer ownership. The new owner will have management access to the case.