async def on_guild_remove(self, guild): del Utils.GUILD_CONFIGS[guild.id] # keep guild record and clear channel configs and default lang guild_row = Guild.get(serverid=guild.id) guild_row.memberrole = 0 guild_row.nonmemberrole = 0 guild_row.mutedrole = 0 guild_row.welcomechannelid = 0 guild_row.ruleschannelid = 0 guild_row.logchannelid = 0 guild_row.entrychannelid = 0 guild_row.rulesreactmessageid = 0 guild_row.defaultlocale = '' guild_row.save()
async def add_channel(self, ctx, channel: TextChannel, platform, branch): try: guild_row = Guild.get(serverid=ctx.guild.id) except DoesNotExist: await ctx.send(f"I couldn't find a record for guild id {ctx.guild.id}... call a plumber!") return try: platform_row = BugReportingPlatform.get(platform=platform, branch=branch) except DoesNotExist: await ctx.send(f"I couldn't find a record for platform/branch `{platform}`/`{branch}`") return try: record, created = BugReportingChannel.get_or_create(guild=guild_row, platform=platform_row, channelid=channel.id) except IntegrityError: await ctx.send(f"channel{channel.mention} is already in used for bug reporting") return if created: await ctx.send(f"{channel.mention} will now be used to record `{platform}/{branch}` bug reports") else: await ctx.send(f"{channel.mention} was already configured for `{platform}/{branch}` bug reports")
async def permission_config(self, ctx): is_bot_admin = await self.bot.permission_manage_bot(ctx) embed = discord.Embed(timestamp=ctx.message.created_at, color=0x663399, title=Lang.get_locale_string( "permission_config/info", ctx, server_name=ctx.guild.name)) embed.add_field( name='Configurable Permissions', value= f"Trusted Roles, Mod Roles, Admin Roles{', Bot Admins' if is_bot_admin else ''}", inline=False) admin_roles = set() mod_roles = set() trusted_roles = set() user_permissions = set() guild_row = Guild.get(serverid=ctx.guild.id) for row in guild_row.admin_roles: role = ctx.guild.get_role(row.roleid) if role: admin_roles.add(role.mention) for row in guild_row.mod_roles: role = ctx.guild.get_role(row.roleid) if role: mod_roles.add(role.mention) for row in guild_row.trusted_roles: role = ctx.guild.get_role(row.roleid) if role: trusted_roles.add(role.mention) for row in guild_row.command_permissions: member = ctx.guild.get_member(row.userid) if member: member_desc = Utils.get_member_log_name(member) desc = f"{member_desc} - `{'ALLOW' if row.allow else 'DENY'}`: `{row.command}`" user_permissions.add(desc) embed.add_field(name="Admin Roles", value='\n'.join(admin_roles), inline=False) embed.add_field(name="Mod Roles", value='\n'.join(mod_roles), inline=False) embed.add_field(name="Trusted Roles", value='\n'.join(trusted_roles), inline=False) embed.add_field(name="User Permissions", value='\n'.join(user_permissions), inline=False) if is_bot_admin: bot_admins = set() for row in BotAdmin.select(): user = self.bot.get_user(row.userid) bot_admins.add(f"{user.mention} {str(user)} ({user.id})") embed.add_field(name="Bot Admins", value='\n'.join(bot_admins), inline=False) await ctx.send(embed=embed)