示例#1
0
 async def predicate(ctx: commands.Context):
     config: Config = ctx.bot.config
     is_admin: bool = await config.is_admin(ctx.author)
     if is_admin:
         return True
     else:
         raise NotOwner(f"{ctx.author} tried to use admin command")
示例#2
0
async def is_owner(ctx):
    """
    Check if the user is bot owner.
    :param ctx: the discord context
    :return: True if the user is the bot owner.
    """
    if not (await ctx.bot.is_owner(ctx.author)):
        raise NotOwner('This is an owner only command.')
    return True
示例#3
0
    async def predicate(ctx):
        if not await ctx.bot.is_owner(ctx.author):
            embed = discord.Embed()

            embed.set_author(name=f' | You do not own this bot.',
                             url=ctx.author.avatar_url,
                             icon_url=ctx.author.avatar_url)

            await ctx.channel.send(embed=embed)
            raise NotOwner(
                f"({ctx.author.name}#{ctx.author.discriminator} | {str(ctx.author.id)}) to run a system that shouldn't."
            )
        return True
示例#4
0
def is_owner(ctx):
    """
    Simple check to see if the user invoking a command is the owner

    Parameters
    ----------
    ctx : discord.ext.commands.Context
        Represents the context in which a command is being invoked under.

    Returns
    -------
    bool:
        True or False if user is an elder
    """
    if ctx.author.id == 265368254761926667:
        return True
    else:
        raise NotOwner("Not owner")
示例#5
0
 def getConfigFromUser(self, user_id, server_id=None):
     if not self.connection:
         raise ValueError("Connection does not exist")
     cursor = self.connection.cursor()
     if server_id is not None:  # If server_id is passed as well then use it
         sql_select_query = "SELECT * from tblServerConfig WHERE Server_Owner_Id = %s AND Server_Id = %s"
         cursor.execute(sql_select_query, (user_id, server_id))
     else:
         sql_select_query = "SELECT * from tblServerConfig WHERE Server_Owner_Id = %s"
         cursor.execute(sql_select_query, (user_id,))
     records = cursor.fetchall()
     self.connection.commit()
     cursor.close()
     if len(records) == 0:  # If no records are returned, then issue an error
         raise NotOwner("You are not the admin of any server")
     elif len(records) == 1:
         return records[0]  # If only 1 record is present, reurn it
     else:
         # If multiple records are present, then raise an Error
         raise AttributeError("Author admin of multiple servers")
示例#6
0
    def modifyServerConfig(self, server_owner_id, server_id=None, count=None, threshold=None):
        record = self.getConfigFromUser(server_owner_id, server_id)  # Get the server record
        if record[3] != server_owner_id:  # If user is not an admin of the server, raise an error
            raise NotOwner("You are not the admin of this server")
        SERVER_ID = record[0]
        if count is None:  # If values are not provided, then use the value in the record
            count = record[1]
        if threshold is None:
            threshold = record[2]

        # Update SQL query
        sql_update_query = """ UPDATE tblServerConfig
            SET Toxic_Limit = %s,
            Toxic_Time_Threshold = %s
            WHERE Server_Id = %s
            """
        cursor = self.connection.cursor()
        cursor.execute(sql_update_query, (count, threshold, SERVER_ID))
        self.connection.commit()
        cursor.close()
        return SERVER_ID  # Returns the server id
示例#7
0
 async def cog_check(self, ctx: Context):
     if not await self.bot.is_owner(ctx.author):
         raise NotOwner()
     return True
 def __local_check(self, ctx):  # All of this cog is only available to devs
     if ctx.author.id not in ctx.bot.config['developers']:
         raise NotOwner('you are not a developer!')
     return True
示例#9
0
 async def __local_check(self, ctx: Context):
     x = await is_owner(ctx)
     if x:
         return True
     raise NotOwner()
示例#10
0
 async def cog_command_error(self, ctx: Context,
                             error: Type[CommandError]) -> None:
     if isinstance(error, CheckFailure):
         raise NotOwner("You do not own this bot.")
     raise error
示例#11
0
 async def cog_before_invoke(self, ctx):
     """Owner only cog"""
     if not await self.bot.is_owner(ctx.author):  # silent error
         message = 'You must own this bot to load extensions'
         raise NotOwner(message=message)
示例#12
0
async def predicate(ctx: Context):
    default = await ctx.bot.is_owner(ctx.author)
    custom = ctx.bot.config['Owner IDs']
    if default or ctx.author.id in custom:
        return True
    raise NotOwner()