Exemplo n.º 1
0
 async def cog_command_error(self, ctx: Context, error: CommandError):
     # TODO: More comprehensive list of errors and proper handlers
     if isinstance(error, MissingRequiredArgument):
         return await KaiserModule.send_error(
             ctx, f'Missing Argument',
             'The command you tried to run ({ctx.message.content}), requires an argument you didn\'t provide: {error}'
         )
     Logger.warning(f'Error in {self.name}: {error}')
Exemplo n.º 2
0
 async def on_command_error(self, ctx: Context, error: CommandError):
     if isinstance(error, CommandNotFound):
         return await KaiserModule.send_error(
             ctx, 'Command Not Found',
             f'The command you tried to run ({ctx.message.content}), does not exist'
         )
     # TODO: More comprehensive list of errors and proper handlers
     Logger.warning(f'Unhandled error type {type(error)}')
     await KaiserModule.send_error(ctx)
Exemplo n.º 3
0
    def database_read(self,
                      key: str,
                      field: str = 'UserData',
                      user_id: int = 0,
                      subfield_override=False):
        if subfield_override:
            if not subfield_override == 'Common':
                Logger.warning("Cross-module database access is discouraged")
        else:
            subfield_override = self.name

        if field == 'UserData':
            return Database.database[field][user_id][subfield_override][key]
        else:
            return Database.database[field][subfield_override][key]