This Discord bot is designed to allow easy member management in a society discord.
You need 2 things for this bot to work:
- Access to the members list for your society, found on a url like
https://student-dashboard.sums.su/groups/336/members
- A Discord bot and token for it
- Install a cookie viewer extension/addon for your browser (I used Cookie Quick Manager)
- Login to your student dashboard
- Using your cookie tool, find the cookie with url
student-dashboard.sums.su
and namesu_session
. - Save the value of that cookie, it should look something like this:
dvpsnk67tme2eal2qu44627o4p20iviv
- Note that the IP that you obtain the cookie from must be the same one that the bot will use.
- Create a new application on the Discord developer portal
- Add a Bot to your application
- Press
Reset Token
and save the token that gets generated - Disable the
PUBLIC BOT
option - Under
Privileged Gateway Intents
, enableMessage Content Intent
- In your application settings, go to
OAuth2 > URL Generator
and create a link:- Under
SCOPES
, check thebot
andapplications.commands
boxes - Under
BOT PERMISSIONS
, checkManage Roles
,Manage Nicknames
,Read Messages/View Channels
andSend Messages
- Open the generated URL and add the bot to your desired server
- In your server, you can allow the bot into specific channels etc via its role.
- Under
- Create a folder on a linux machine with docker installed
- Download the docker-compose.yml and place it in that folder
- Download the example.env, rename it to
.env
and place it in the same folder - Fill out the
.env
file with the details we collected earlier, there's a breakdown of each variable below. The mandatory ones are:DISCORD_TOKEN
,MEMBERS_URL
andINITIAL_SUMS_COOKIE_VALUE
- Start the container with
docker-compose up -d
and check the logs withdocker-compose logs
- In your Discord server, send a message (where the bot can see it):
bruce!setup_commands
, this will give Discord the list of slash commands the bot has. - Now you can use the slash commands by typing a
/
and picking the one you want.
Key | Optional | Default | Example | Description |
---|---|---|---|---|
MEMBERS_URL | False | N/A | https://student-dashboard.sums.su/groups/336/members | This page should contain the list of members of your society |
DISCORD_TOKEN | False | N/A | GHk1MzU6MDkwODk3MTA4OTad.GmurJI.1DH4qad-Q635rkYvaRDfPRl1u5HM--8kKUH_aZ | This is the token we got from the Discord developers portal above |
INITIAL_SUMS_COOKIE_VALUE | True (but you'll need it for the first run or if the token expires) | N/A | dlesnk67tme2eal2qu44627o4p69iviq | This is the value we got from the cookie tool |
MEMBER_ROLE_NAME | True | Member | N/A | This is the role that the bot will give your members |
PRIVILEGED_ROLE_NAME | True | Committee | N/A | This is the role of people that can run the bots management commands |
MEMBERSHIP_PURCHASE_URL | True | N/A | https://su.nottingham.ac.uk/shop/product/31-computer-science-membership | This is a link that your members can go to to purchase a membership |
Bruce has 3 main commands:
Register allows any user to provide their student id to verify that they are a member of the society. If the check passes, Bruce will give them your defined member role and also set their nickname to their real name.
Unregister allows privileged users (usually committee) to unregister a specific discord user in the event something goes awry. For example, a user may /register with a student id other than their own.
Unregistering a user should be done via Bruce otherwise Bruce will still think that the user is registered. Removing the user's role is not enough.
Prune allows privileged users (usually committee) to bulk unregister users whose memberships have expired. This would be a scheduled task however since memberships can be bought at any time of the year, I decided to leave it up to the society to decide when to prune.