Alliance Auth Discord Bot
allianceauth-discordbot is a modular Discord bot designed to integrate deeply with Alliance Auth, a Django-based authentication system for EVE Online alliances. It provides features like user lookup, permissions management, and custom commands, leveraging Django's ORM and authentication. The current version is 5.0.0, and it maintains an active release cadence, often pushing minor updates and bug fixes.
Common errors
-
ModuleNotFoundError: No module named 'aadiscordbot.providers.esi'
cause Attempting to import or use the internal ESI provider after upgrading to version 5.0.0, where it was removed.fixRemove all references to `aadiscordbot.providers.esi` from your custom cogs and use an external ESI library or implement your own API calls instead. -
RuntimeError: You must run the bot in a Django environment.
cause The `python manage.py runbot` command was executed outside of a valid Django project context (e.g., not from the directory containing `manage.py`) or before Django is fully set up.fixNavigate to your Django project's root directory (where `manage.py` is located) and ensure your Django `settings.py` is correctly configured before running `python manage.py runbot`. -
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
cause The Discord bot token provided to `AABOT_TOKEN` does not have the necessary permissions enabled in the Discord Developer Portal, or the bot has not been granted required permissions in the Discord server.fixGo to the Discord Developer Portal, select your bot, and ensure all necessary Gateway Intents are enabled (e.g., Message Content Intent, Privileged Intents). Also, ensure the bot has the required permissions in the Discord server settings. -
Command 'my_command_name' is not found
cause A custom cog containing the command was not loaded correctly, or the bot's prefix is incorrect.fixVerify that your custom cog's module path is correctly listed in `AABOT_COG_PATH` in `settings.py`. Check for any errors during bot startup that indicate a cog failed to load. Ensure you are using the correct command prefix defined by `AABOT_PREFIX`.
Warnings
- breaking The internal ESI provider has been removed in version 5.0.0. If you had custom cogs or extensions that relied on `aadiscordbot.providers.esi` for EVE Online ESI data, they will no longer function.
- breaking Version 4.0.0 introduced significant changes to custom task functionality and helper modules for external services. While not all changes are directly breaking, custom implementations relying on older patterns for tasks or inter-module communication might need updates.
- gotcha allianceauth-discordbot requires Python 3.8 or higher. Attempting to install or run the bot with older Python versions will result in dependency resolution failures or runtime errors.
- gotcha When developing custom cogs, ensure that `aadiscordbot` and your custom cog's Django app are correctly listed in `INSTALLED_APPS` and `AABOT_COG_PATH` in your Django `settings.py`. Forgetting this is a common cause of cogs not loading.
Install
-
pip install allianceauth-discordbot
Imports
- commands
from discord.ext import commands
- has_perm
from aadiscordbot.cogs.utils.decorators import has_perm
- AABot
from aadiscordbot.bot import DiscordBot
from aadiscordbot.bot import AABot
Quickstart
import discord
from discord.ext import commands
from aadiscordbot.cogs.utils.decorators import has_perm
# This cog should be placed within a Django app included in INSTALLED_APPS
# and its path added to AABOT_COG_PATH in your Django settings.
class MyCustomCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.hybrid_command(name="myhello")
@has_perm("aadiscordbot.basic_access") # Requires 'Basic Access' permission in Alliance Auth
async def my_hello_command(self, ctx: commands.Context):
"""Greets the user from Alliance Auth bot."""
await ctx.send(f"Hello from your custom cog, {ctx.author.display_name}!", ephemeral=True)
@commands.hybrid_command(name="myping")
async def my_ping_command(self, ctx: commands.Context):
"""Responds with the bot's latency."""
await ctx.send(f"Pong! {round(self.bot.latency * 1000)}ms", ephemeral=True)
async def setup(bot):
# This 'setup' function is called by the bot to load the cog.
await bot.add_cog(MyCustomCog(bot))
# To run the bot, ensure it's configured in your Django settings (settings.py):
# INSTALLED_APPS = [
# ...,
# 'aadiscordbot',
# 'my_django_app' # Where your custom cogs reside
# ]
#
# AABOT_TOKEN = os.environ.get('AABOT_TOKEN', 'YOUR_DISCORD_BOT_TOKEN')
# AABOT_PREFIX = '!'
# AABOT_COG_PATH = ['my_django_app.cogs'] # List of paths to your cog modules
#
# Then, from your Django project root:
# python manage.py runbot