Discord Service
This page contains the technical documentation for the Discord service.
Location: allianceauth.services.modules.discord
api
Public interface for community apps who want to interact with the Discord server of the current Alliance Auth instance.
Example
Here is an example for using the api to fetch the current roles from the configured Discord server.
from allianceauth.services.modules.discord.api import create_bot_client, discord_guild_id
client = create_bot_client() # create a new Discord client
guild_id = discord_guild_id() # get the ID of the configured Discord server
roles = client.guild_roles(guild_id) # fetch the roles from our Discord server
See also
The docs for the client class can be found here: DiscordClient
- class DiscordUser(*args, **kwargs)[source]
The Discord user account of an Auth user.
- Parameters:
uid (BigIntegerField) – Uid. user’s ID on Discord
username (CharField) – Username. user’s username on Discord
discriminator (CharField) – Discriminator. user’s discriminator on Discord
activated (DateTimeField) – Activated. Date & time this service account was activated
Relationship fields:
- Parameters:
user (
OneToOneField
toUser
) – Primary key: User. Auth user owning this Discord account (related name:discord
)
- class Role(id: int, name: str, managed: bool = False)[source]
A role on Discord.
- create_bot_client(is_rate_limited: bool = True) DiscordClient [source]
Create new bot client for accessing the configured Discord server.
- Parameters:
is_rate_limited – Set to False to turn off rate limiting (use with care).
- Returns:
Discord client instance
settings
- DISCORD_APP_ID = 'appid'
App ID for the AA bot on Discord. Needs to be set.
- DISCORD_APP_SECRET = 'secret'
App secret for the AA bot on Discord. Needs to be set.
- DISCORD_BOT_TOKEN = 'bottoken'
Token used by the AA bot on Discord. Needs to be set.
- DISCORD_CALLBACK_URL = 'http://example.com/discord/callback'
Callback URL for OAuth with Discord. Needs to be set.
- DISCORD_GUILD_ID = '0118999'
ID of the Discord Server. Needs to be set.
- DISCORD_SYNC_NAMES = False
Automatically sync Discord users names to user’s main character name when created.
- DISCORD_TASKS_MAX_RETRIES = 3
Max retries of tasks after an error occurred.
- DISCORD_TASKS_RETRY_PAUSE = 60
Pause in seconds until next retry for tasks after the API returned an error.