2024-01-13 10:44:08 -05:00
from redbot . core import commands
from redbot . core . utils . chat_formatting import error , warning
2024-01-16 07:59:15 -05:00
from aurora . configuration . menus . addrole import Addrole
2024-01-16 09:02:10 -05:00
from aurora . configuration . menus . guild import Guild
2024-01-16 07:59:15 -05:00
from aurora . configuration . menus . immune import Immune
2024-01-16 05:31:11 -05:00
from aurora . configuration . menus . overrides import Overrides
2024-01-16 06:50:09 -05:00
from aurora . configuration . embed import addrole , overrides , immune , guild
2024-01-15 10:01:20 -05:00
from aurora . abc import Mixin
from aurora . importers . aurora import ImportAuroraView
from aurora . importers . galacticbot import ImportGalacticBotView
2024-01-13 10:44:08 -05:00
2024-01-15 09:03:02 -05:00
2024-01-13 10:44:08 -05:00
class Configuration ( Mixin ) :
""" Configuration commands for Aurora. """
2024-01-15 09:03:02 -05:00
@commands.group ( autohelp = True , aliases = [ " moderation " , " mod " ] )
2024-01-15 01:46:12 -05:00
async def aurora ( self , ctx : commands . Context ) :
""" Settings and miscellaneous commands for Aurora. """
2024-01-13 10:44:08 -05:00
2024-01-15 09:04:51 -05:00
@aurora.group ( autohelp = True , name = " settings " , aliases = [ " config " , " options " , " set " ] )
2024-01-15 01:46:12 -05:00
async def aurora_settings ( self , ctx : commands . Context ) :
2024-01-15 09:04:51 -05:00
""" Configure Aurora ' s settings. """
2024-01-16 06:24:39 -05:00
@aurora_settings.command ( name = " overrides " , aliases = [ " override " , " user " ] )
async def aurora_settings_overrides ( self , ctx : commands . Context ) :
2024-01-16 05:31:11 -05:00
""" Manage Aurora ' s user overriddable settings. """
2024-01-16 06:50:09 -05:00
await ctx . send ( embed = await overrides ( ctx ) , view = Overrides ( ctx ) )
@aurora_settings.command ( name = " guild " , aliases = [ " server " ] )
2024-01-16 06:53:22 -05:00
@commands.admin_or_permissions ( manage_guild = True )
@commands.guild_only ( )
2024-01-16 06:50:09 -05:00
async def aurora_settings_guild ( self , ctx : commands . Context ) :
""" Manage Aurora ' s guild settings. """
2024-01-16 09:02:10 -05:00
await ctx . send ( embed = await guild ( ctx ) , view = Guild ( ctx ) )
2024-01-15 01:46:12 -05:00
2024-01-15 09:03:02 -05:00
@aurora_settings.command ( name = " addrole " , aliases = [ " removerole " ] )
@commands.admin_or_permissions ( manage_guild = True )
2024-01-16 06:53:22 -05:00
@commands.guild_only ( )
2024-01-15 09:03:02 -05:00
async def aurora_settings_addrole ( self , ctx : commands . Context ) :
""" Manage the addrole whitelist.
Roles added to this list are also applied to ` / removerole ` . """
2024-01-16 07:59:15 -05:00
await ctx . send ( embed = await addrole ( ctx ) , view = Addrole ( ctx ) )
2024-01-15 09:03:02 -05:00
@aurora_settings.command ( name = " immunity " )
@commands.admin_or_permissions ( manage_guild = True )
2024-01-16 06:53:22 -05:00
@commands.guild_only ( )
2024-01-15 09:03:02 -05:00
async def aurora_settings_immunity ( self , ctx : commands . Context ) :
""" Manage the immunity whitelist. """
2024-01-16 07:59:15 -05:00
await ctx . send ( embed = await immune ( ctx ) , view = Immune ( ctx ) )
2024-01-15 09:03:02 -05:00
@aurora.group ( autohelp = True , name = " import " )
2024-01-13 10:44:08 -05:00
@commands.admin ( )
@commands.guild_only ( )
2024-01-15 01:46:12 -05:00
async def aurora_import ( self , ctx : commands . Context ) :
2024-01-15 09:29:13 -05:00
""" Import moderation history from other bots. """
2024-01-13 10:44:08 -05:00
2024-01-15 01:46:12 -05:00
@aurora_import.command ( name = " aurora " )
2024-01-13 10:44:08 -05:00
@commands.admin ( )
2024-01-15 06:49:20 -05:00
async def aurora_import_aurora ( self , ctx : commands . Context ) :
2024-01-15 09:29:13 -05:00
""" Import moderation history from another bot using Aurora. """
2024-01-15 09:03:02 -05:00
if (
ctx . message . attachments
and ctx . message . attachments [ 0 ] . content_type
== " application/json; charset=utf-8 "
) :
message = await ctx . send (
warning (
" Are you sure you want to import moderations from another bot? \n **This will overwrite any moderations that already exist in this guild ' s moderation table.** \n *The import process will block the rest of your bot until it is complete.* "
)
)
2024-01-13 10:44:08 -05:00
await message . edit ( view = ImportAuroraView ( 60 , ctx , message ) )
else :
await ctx . send ( error ( " Please provide a valid Aurora export file. " ) )
2024-01-15 01:46:12 -05:00
@aurora_import.command ( name = " galacticbot " )
2024-01-13 10:44:08 -05:00
@commands.admin ( )
2024-01-15 06:49:20 -05:00
async def aurora_import_galacticbot ( self , ctx : commands . Context ) :
2024-01-15 09:29:13 -05:00
""" Import moderation history from GalacticBot. """
2024-01-15 09:03:02 -05:00
if (
ctx . message . attachments
and ctx . message . attachments [ 0 ] . content_type
== " application/json; charset=utf-8 "
) :
message = await ctx . send (
warning (
" Are you sure you want to import GalacticBot moderations? \n **This will overwrite any moderations that already exist in this guild ' s moderation table.** \n *The import process will block the rest of your bot until it is complete.* "
)
)
2024-01-13 10:44:08 -05:00
await message . edit ( view = ImportGalacticBotView ( 60 , ctx , message ) )
else :
2024-01-15 09:03:02 -05:00
await ctx . send (
error ( " Please provide a valid GalacticBot moderation export file. " )
)