This script integrates with WoWChat/AscensionChat to automatically assign roles to Discord server members based on their character names in the ?who
reply.
Note
In-game and Discord Nicknames must match for this to work.
The script uses the discord.py
library to interact with the Discord API. It sends a ?who
command to the specified channel, which triggers the WoWChat/AscensionChat bot to respond with a list of currently online guild members. The script then extracts the character names using regular expressions (regex) and assigns the specified role to Discord server members with matching names. It will then continue to monitor the specified channel while running. If anyone sends a ?who
command in the monitored channel, this bot will once again parse the response and assign roles to those without the role already.
- Go to the Discord Developer Portal and create a new app/bot
- Click the
Bot
tab on the left side. - Copy your bot
TOKEN
. (You might need to reset it first) - Disable
Public Bot
.
[!IMPORTANT] 5. Under
Without these enabled the bot will not work!Privileged Gateway Intents
: EnableServer Members Intent
andMessage Content Intent
.
- To skip steps 7-9:
-
Copy this link, making sure to replace
YOUR_CLIENT_ID
with your bot's client ID. Open the link in your browser to invite the bot.https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&permissions=268503040&integration_type=0&scope=bot
-
Go to the
OAuth2
tab and selectbot
underOAuth2 URL Generator -> Scopes
[!IMPORTANT] 8. Underneath
Make sure these are correct! Incorrect permissions will cause issues with the bot's functions!Scopes
, inBot Permissions
select:Manage Roles
,Send Messages
andRead Message History
.
- Copy the generated URL and open it in a browser. You can now invite the bot to your Discord Server.
-
Install Python 3.8 or higher, if you don't have it installed already.
-
Open your terminal and navigate to the WoWChat-AutoRoles directory.
-
Run the following command to install (or update if you already have) the dependencies
discord.py
,python-dotenv
andcolorama
:pip install -U -r requirements.txt
- Open
CONFIG.env
in your favorite text editor. WHO_INTERVAL_ENABLED
SetTrue
orFalse
depending on if you want the bot to auto send?who
at a specified interval. Default is false.WHO_INTERVAL_HOURS
Set how often (in hours) the bot should send the?who
command, if set toTrue
above- Replace
YourTokenHere
with your Discord bot token. - Replace
YourServerId
with your Discord server ID. - Replace
YourChannelID
with the Channel ID of the channel this bot will monitor for the?who
command. - Replace
YourRoleName
with the name of the role you want the bot to assign. - Replace
YourWowChatBotName
with the name of your WoWChat/AscensionChat bot. (your bot that replies to the?who
command)
- Save your config changes and rename
CONFIG.env
to just.env
. - Open your terminal and
cd
into the directory you savedautoroles.py
to. (eg,cd ~/Downloads/autoroles
) - Run the script using Python:
- Linux/MacOS:
python3 autoroles.py
- Windows:
python.exe autoroles.py
- Linux/MacOS: