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
Bottab on the left side. - Copy your bot
TOKEN. (You might need to reset it first) - Disable
Public Bot.
Important
5. Under Privileged Gateway Intents: Enable Server Members Intent and Message Content Intent.
- To skip steps 7-9:
-
Copy this link, making sure to replace
YOUR_CLIENT_IDwith 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
OAuth2tab and selectbotunderOAuth2 URL Generator -> Scopes
Important
8. Underneath Scopes, in Bot Permissions select: Manage Roles, Send Messages and Read 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-dotenvandcolorama:pip install -U -r requirements.txt
- Open
CONFIG.envin your favorite text editor. WHO_INTERVAL_ENABLEDSetTrueorFalsedepending on if you want the bot to auto send?whoat a specified interval. Default is false.WHO_INTERVAL_HOURSSet how often (in hours) the bot should send the?whocommand, if set toTrueabove- Replace
YourTokenHerewith your Discord bot token. - Replace
YourServerIdwith your Discord server ID. - Replace
YourChannelIDwith the Channel ID of the channel this bot will monitor for the?whocommand. - Replace
YourRoleNamewith the name of the role you want the bot to assign. - Replace
YourWowChatBotNamewith the name of your WoWChat/AscensionChat bot. (your bot that replies to the?whocommand) - Save your config changes and rename
CONFIG.envto just.env.
- Open your terminal and
cdinto thesrcdirectory thatautoroles.pyis saved in. (eg,cd ~/Downloads/WoWChat-AutoRoles/src) - Run the script using Python:
- Linux/MacOS:
python3 autoroles.py - Windows:
python.exe autoroles.py
- Linux/MacOS:


