Package: allianceauth-discordbot
AA-DiscordbotAA-Discordbot forAlliance Auth.FeaturesBot Framework, easily extensible with more CogsIntegration with Alliance Auth, able to fetch data directly from its django project.Channel/Direct messaging feature, with Tasks and a Queue/ConsumerCurrent CogsAbout!about - Bot Information and StatisticsAuth!auth or /auth - A direct link to the Auth Install to catch users familiar with other bots.Members!lookup [search string] - Fetch a users Main, Affiliation, State, Groups and linked characters from any character.!altcorp [search string] - search for users with characters in an altcorpRemind!remindme [5s/m/h/d text] - Sets a simple non-persistent reminder timer when the bot will respond with the textSov!vuln [context] - Returns a list of Vulnerable sov structures for a Region/Constellation/Solar_System or alliance!sov [context] - Returns a list ofallsov structures for a Region/Constellation/Solar_System or alliance!lowadm - Lists sov in need of ADM-ing, context provided in settings.Time!time or /time - Returns the current EVE Time.Timers!timer - Returns the next Structure timer from allianceauth.timerboard.Ticket/help and Message context command to create private support threadsPriceCheck:amarr - Check an item price on Amarr marketjita -  Check an item price on Jita marketprice - Check an item price on Jita and Amarr marketEaster Eggs,!happybirthday [text] - Wishes the text a happy birthday, works with user mentionsWelcomeGoodbyeWelcome - Responds to user join events with predefined messages.Goodbye - Responds to user leave events with predefined messages.AdminSlash commands to help with setting up a discord server when you are not admin or owner.accessed via/admin [command]add_role / add_role_read / rem_role - add/remove a role to a channelnew_channel - create a new channel and assign it a role for read accesspromote_role_to_god/demote_role_to_god - promote/demote a role to/from full admin so for when you need itempty_roles - list all roles on server with no membersclear_empty_roles - remove all empty roles from the serverorphans - find any user in discord with no auth user attachedget_webhooks - returns any webhooks setup in this current channel, or creates one for you and returns thatuptime - how long the bot has been up forInstallationEnsure you have installed and configured the Alliance Auth Discord Service,https://allianceauth.readthedocs.io/en/latest/features/services/discord.htmlUpdate yourDiscord Developer Applicationto include the Privileged Intents that we call. Please enable all intents.Install the app with your venv activepipinstallallianceauth-discordbotAdd'aadiscordbot',and'solo',to your INSTALLED_APPS list in local.py.Add the below lines to yourlocal.pysettings file, Changing the contexts to yours.## Settings for Allianceauth-Discordbot# Admin CommandsADMIN_DISCORD_BOT_CHANNELS=[111,222,333]# Sov CommandsSOV_DISCORD_BOT_CHANNELS=[111,222,333]# Adm CommandsADM_DISCORD_BOT_CHANNELS=[111,222,333]DISCORD_BOT_SOV_STRUCTURE_OWNER_IDS=[1000169]# Centre for Advanced Studies exampleDISCORD_BOT_MEMBER_ALLIANCES=[111,222,333]# A list of alliances to be considered "Mains"DISCORD_BOT_ADM_REGIONS=[10000002]# The Forge ExampleDISCORD_BOT_ADM_SYSTEMS=[30000142]# Jita ExampleDISCORD_BOT_ADM_CONSTELLATIONS=[20000020]# Kimitoro ExamplePRICE_CHECK_HOSTNAME="evepraisal.com"# Point to your favorite evepraisal## Insert AADiscordBot's logging into Django Logging configLOGGING['handlers']['bot_log_file']={'level':'INFO','class':'logging.handlers.RotatingFileHandler','filename':os.path.join(BASE_DIR,'log/discord_bot.log'),'formatter':'verbose','maxBytes':1024*1024*5,'backupCount':5,}LOGGING['loggers']['aadiscordbot']={'handlers':['bot_log_file'],'level':'DEBUG'}Add the below lines tomyauth/celery.pysomewhere above theapp.autodiscover_tasks...line## Route AA Discord bot tasks away from AllianceAuthapp.conf.task_routes={'aadiscordbot.tasks.*':{'queue':'aadiscordbot'}}Run migrationspython manage.py migrate(There should be none from this app)Gather your static filespython manage.py collectstatic(There should be none from this app)Fetchbot_conf.pyfrom the Git Repo into the root of your AA install, besidemanage.pywgethttps://raw.githubusercontent.com/pvyParts/allianceauth-discordbot/master/bot_conf.pyAmend your supervisor.conf, correcting paths as required and addauthbotto the launch group at the end of the conf[program:authbot]command=/home/allianceserver/venv/auth/bin/python /home/allianceserver/myauth/bot_conf.pydirectory=/home/allianceserver/myauthuser=allianceservernumprocs=1autostart=trueautorestart=truestopwaitsecs=600stdout_logfile=/home/allianceserver/myauth/log/authbot.logstderr_logfile=/home/allianceserver/myauth/log/authbot.log#This block should already exist, add authbot to it[group:myauth]programs=beat,worker,gunicorn,authbotpriority=999Go to admin and configure your admin users in the bot config model.Enable groups/states/users to utilize the lookup command by adding permissions undercorputils | corp stats |corputils.view_alliance_corpstatsOptional SettingsBuilt in Cogs# Change the bots default Cogs, add or remove if you want to use any of the extra cogs.DISCORD_BOT_COGS=["aadiscordbot.cogs.about",# about the bot"aadiscordbot.cogs.admin",# Discord server admin helpers"aadiscordbot.cogs.members",# Member lookup commands"aadiscordbot.cogs.timers",# timer board integration"aadiscordbot.cogs.auth",# return auth url"aadiscordbot.cogs.sov",# some sov helpers"aadiscordbot.cogs.time",# whats the time Mr Eve Server"aadiscordbot.cogs.eastereggs",# some "fun" commands from ariel..."aadiscordbot.cogs.remind",# very Basic in memory reminder tool"aadiscordbot.cogs.reaction_roles",# auth group integrated reaction roles"aadiscordbot.cogs.services",# service activation data"aadiscordbot.cogs.price_check",# Price Checks"aadiscordbot.cogs.eightball",# 8ball should i install this cog"aadiscordbot.cogs.welcomegoodbye",# Customizable user join/leave messages"aadiscordbot.cogs.models",# Populate and Maintain Django Models for Channels and Servers"aadiscordbot.cogs.quote",# Save and recall messages"aadiscordbot.cogs.prom_export",# Admin Level Logging cog"aadiscordbot.cogs.tickets",# Private thread ticket system with pingable groups.]Additional Rate Limiting# configure the optional rate limited# this is a bot_task function and how many / time period# 100/s equates to 100 per second max# 10/m equates to 10 per minute or 1 every 6 seconds max# 60/h equates to 60 per hour or one per minute maxDISCORD_BOT_TASK_RATE_LIMITS={"send_channel_message_by_discord_id":"100/s","send_direct_message_by_discord_id":"1/s","send_direct_message_by_user_id":"1/s"}Reaction Roles❗❗❗This will bypass the Group Leadership/Join Request System: This is intended for open groups but not limited to it! ❗❗❗The bot is able to run a reaction roles system that is compatible with auth and public users on a discord.If a member is part of auth it will do auth syncing of rolesIf a member is not found in auth and the reaction role message has the public flag set it will assign roles to anyone who reactsHow To Reaction Role!Setup the inital Message you wish to use buy using the command!rrOptionalEdit the name and settings of this message inAdmin > Discord Bot > Reaction Role MessagesReact to the message with the reactions you wish to use.The bot will counter react to the reactions when it creates the binding in auth.GotoAdmin > Discord Bot > Reaction Role BindingsAssign the groups you want for each reactionMessages AdminReactions AdminIntegrationsStatisticsAdds zkill Monthly/Yearly stats to !lookuptimezonesUpdates thetimecommand to have all timezones configured in auth.Welcome Messaages`
With the WelcomeGoodbye Cog activated, Discordbot will grab a random message from the Welcome or Goodbye Message Model and send it to the Guild System channelThese can be configured in admin under/admin/aadiscordbot/welcomemessage/and/admin/aadiscordbot/goodbyemessage/The messages support some string formatting`{user_mention} - A Discord @ Mention`{guild_name} - The name of the Discord Server`{auth_url} - A link to AuthWelcome {user_mention} to {guild_name}, I hope you enjoy your stay.

You can Authenticate for more access {auth_url}Private Thread Ticket System❗❗❗While this is fully functional, this is still in early stages of development, Please report any issues you find!❗❗❗With theaadiscordbot.cogs.ticketsCog activated, users wll be able to issue the/helpcommand to pick a group to get help from.The groups available for selection are configurable in the site admin underDiscord Bot > Ticket Cog ConfigurationYou also need to choose a channel to create the threads in from the site adminDiscord Bot > Ticket Cog Configuration:Anyone who can use the/helpcommand must have View and Send Message permissions on this channel otherwise they will not be able to see the tickets authbot creates for themAuthbot must have the permissions to create private threads in this channelAuthbot must have the permissions to send messages to this channelUsing AA-Discordbot from my projectSend MessagesYou can use the send_message helper to send a message with text/embed to:Discord user_idDiscord channel_idAuth User Model ObjectAuth user_pkaadiscordbot/tasks.pyExample Usagefromdjango.contrib.auth.modelsimportUserfromdjango.appsimportapps## Use a small helper to check if AA-Discordbot is installsdefdiscord_bot_active():returnapps.is_installed('aadiscordbot')## Only import it, if it is installedifdiscord_bot_active():fromaadiscordbot.tasksimportsend_message# if you want to send discord embed import them too.fromdiscordimportEmbed,Color## this helper can be called to Queue up a Message## AA Should not act on these, only AA-DiscordBot will consume themifdiscord_bot_active():usr=User.objects.get(pk=1)# discord ID of usermsg="Channel ID Tests"e=Embed(title="Channel ID Tests!",description="This is a Test Embed.\n\n```Discord Channel ID```",color=Color.yellow())e.add_field(name="Test Field 1",value="Value of some kind goes here")send_message(channel_id=639252062818926642,embed=e)# Embedsend_message(channel_id=639252062818926642,message=msg)# Messagesend_message(channel_id=639252062818926642,message=msg,embed=e)# Both# Discord ID of channelmsg="User ID Tests"e=Embed(title="User ID Tests!",description="This is a Test Embed.\n\n```Discord User ID```",color=Color.nitro_pink())e.add_field(name="Test Field 1",value="Value of some kind goes here")send_message(user_id=318309023478972417,embed=e)# Embedsend_message(user_id=318309023478972417,message=msg)# Messagesend_message(user_id=318309023478972417,message=msg,embed=e)# Both# User modelmsg="Auth User Model Tests"e=Embed(title="Auth User Model Tests!",description="This is a Test Embed.\n\n```Auth User Model```",color=Color.dark_orange())e.add_field(name="Test Field 1",value="Value of some kind goes here")send_message(user=usr,embed=e)# Embedsend_message(user=usr,message=msg)# Messagesend_message(user=usr,message=msg,embed=e)# Both# User PK idmsg="Auth User PK Tests"e=Embed(title="Auth User PK Tests!",description="This is a Test Embed.\n\n```Auth User PK```",color=Color.brand_green())e.add_field(name="Test Field 1",value="Value of some kind goes here")send_message(user_pk=1,embed=e)# Embedsend_message(user_pk=1,message=msg)# Messagesend_message(user_pk=1,message=msg,embed=e)# Both# Mixture of all of the abovemsg="All Together Tests"e=Embed(title="All Together Tests!",description="This is a Test Embed.\n\n```All Together```",color=Color.blurple())e.add_field(name="Test Field 1",value="Value of some kind goes here")send_message(channel_id=639252062818926642,user_id=318309023478972417,user=User.objects.get(pk=1),message=msg,embed=e)Registering 3rd Party Cogs (Handling Commands)Inauth_hooks.py, define a function that returns an array of cog modules, and register it as adiscord_cogs_hook:@hooks.register('discord_cogs_hook')defregister_cogs():return["yourapp.cogs.cog_a","yourapp.cogs.cog_b"]Optional SettingsIsolate AuthBot from Auth's Discord ServiceAUTHBOT_DISCORD_APP_ID='App ID for dedicated bot'AUTHBOT_DISCORD_BOT_TOKEN='Token for dedicated bot'IssuesPlease remember to report any aa-discordbot related issues using the issues onthisrepository.TroubleshootingPy-Cord and discord.py fighting in venvProblem:Something has gone funny with my venv after i installed another app that wanteddiscord.pyReason:This is due to the Py-cord lib sharing thediscordnamespace. Py-Cord is however a drop in replacement. So no issues should arise from using it over the now legacy discord.py lib.YMMVFix:Uninstalldiscord.pyby runningpip uninstall discord.pywith your venv active.Reinstallpy-cordby runningpip install -U py-cord==2.0.0b3with your venv active.Approach the dev from the app that overrode your py-cord to update to a maintained lib.