Ejemplo n.º 1
0
 async def check_command_logging_enabled(self, guild: discord.Guild, min_level: LogLevel, name: str):
     log_channel = await super().check_logging_enabled(guild, min_level)
     async with self.bot.db.acquire() as con:
         command_enabled = await con.fetchval(f"SELECT {name} FROM logging WHERE guild_id={guild.id}")
     if command_enabled:
         return log_channel
     else:
         raise customerrors.LoggingNotEnabled()
Ejemplo n.º 2
0
 async def check_logging_enabled(self,
                                 member: discord.Member,
                                 min_level: LogLevel,
                                 guild: discord.Guild = None):
     if not member.bot:
         return await super().check_logging_enabled(
             member.guild if hasattr(member, "guild") else guild, min_level)
     else:
         raise customerrors.LoggingNotEnabled()
Ejemplo n.º 3
0
    async def check_logging_enabled(self, guild, min_level: LogLevel):
        async with self.bot.db.acquire() as con:
            log_channel = await con.fetchval(f"SELECT log_channel FROM guild WHERE guild_id={guild.id}")
            log_level = await con.fetchval(f"SELECT log_level FROM guild WHERE guild_id={guild.id}")

        if not log_channel or log_channel == "DISABLED":
            raise customerrors.LoggingNotEnabled()
        elif log_level < min_level.value:
            raise customerrors.LoggingLevelInsufficient()
        else:
            return self.bot.get_channel(log_channel)
Ejemplo n.º 4
0
 async def logging_list(self, ctx, *, name: str):
     if name:
         return await self.logging_list_command(ctx, name)
     async with self.bot.db.acquire() as con:
         log_channel = await con.fetchval(
             f"SELECT log_channel FROM guild WHERE guild_id={ctx.guild.id}")
         log_level = LogLevel(await con.fetchval(
             f"SELECT log_level FROM guild WHERE guild_id={ctx.guild.id}"))
     if not log_channel or not log_level:
         raise customerrors.LoggingNotEnabled()
     embed = discord.Embed(
         title="Logging Details",
         description=
         f"**Logging Channel:** {f'<#{log_channel}>' if log_channel else '`None Set`'}\n"
         f"**Logging Level:** `{log_level}`",
         color=discord.Color.blue()
         if log_channel else discord.Color.dark_red())
     return await ctx.channel.send(embed=embed)