fuck: pep-8 79 chars
This commit is contained in:
parent
f6ba42a143
commit
712339968c
1 changed files with 14 additions and 26 deletions
40
bot.py
40
bot.py
|
@ -20,7 +20,7 @@ log = logging.getLogger(__name__)
|
||||||
|
|
||||||
l_extensions = (
|
l_extensions = (
|
||||||
'cogs.admin',
|
'cogs.admin',
|
||||||
'cogs.basics',
|
'cogs.bascics',
|
||||||
'jishaku',
|
'jishaku',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,9 +37,7 @@ class TuxBot(commands.AutoShardedBot):
|
||||||
__slots__ = ('uptime', 'config', 'session')
|
__slots__ = ('uptime', 'config', 'session')
|
||||||
|
|
||||||
def __init__(self, unload: list):
|
def __init__(self, unload: list):
|
||||||
super().__init__(command_prefix=_prefix_callable,
|
super().__init__(command_prefix=_prefix_callable, description=description, pm_help=None, help_command=None, help_attrs=dict(hidden=True))
|
||||||
description=description, pm_help=None,
|
|
||||||
help_command=None, help_attrs=dict(hidden=True))
|
|
||||||
|
|
||||||
self.uptime: datetime = datetime.datetime.utcnow()
|
self.uptime: datetime = datetime.datetime.utcnow()
|
||||||
self.config = config
|
self.config = config
|
||||||
|
@ -54,10 +52,8 @@ class TuxBot(commands.AutoShardedBot):
|
||||||
try:
|
try:
|
||||||
self.load_extension(extension)
|
self.load_extension(extension)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(gettext("Failed to load extension : ") + extension,
|
print(gettext("Failed to load extension : ") + extension, file=sys.stderr)
|
||||||
file=sys.stderr)
|
log.error(gettext("Failed to load extension : ") + extension, exc_info=e)
|
||||||
log.error(gettext("Failed to load extension : ")
|
|
||||||
+ extension, exc_info=e)
|
|
||||||
|
|
||||||
async def is_owner(self, user: discord.User) -> bool:
|
async def is_owner(self, user: discord.User) -> bool:
|
||||||
return user.id in config.authorized_id
|
return user.id in config.authorized_id
|
||||||
|
@ -67,19 +63,16 @@ class TuxBot(commands.AutoShardedBot):
|
||||||
|
|
||||||
async def on_command_error(self, ctx: discord.ext.commands.Context, error):
|
async def on_command_error(self, ctx: discord.ext.commands.Context, error):
|
||||||
if isinstance(error, commands.NoPrivateMessage):
|
if isinstance(error, commands.NoPrivateMessage):
|
||||||
await ctx.author.send(
|
await ctx.author.send(gettext('This command cannot be used in private messages.'))
|
||||||
gettext('This command cannot be used in private messages.')
|
|
||||||
)
|
|
||||||
elif isinstance(error, commands.DisabledCommand):
|
elif isinstance(error, commands.DisabledCommand):
|
||||||
await ctx.author.send(
|
await ctx.author.send(gettext('Sorry. This command is disabled and cannot be used.'))
|
||||||
gettext('Sorry. This command is disabled and cannot be used.')
|
|
||||||
)
|
|
||||||
elif isinstance(error, commands.CommandInvokeError):
|
elif isinstance(error, commands.CommandInvokeError):
|
||||||
print(gettext('In ') + f'{ctx.command.qualified_name}:',
|
print(gettext('In ') + f'{ctx.command.qualified_name}:', file=sys.stderr)
|
||||||
file=sys.stderr)
|
|
||||||
traceback.print_tb(error.original.__traceback__)
|
traceback.print_tb(error.original.__traceback__)
|
||||||
print(f'{error.original.__class__.__name__}: {error.original}',
|
print(f'{error.original.__class__.__name__}: {error.original}', file=sys.stderr)
|
||||||
file=sys.stderr)
|
|
||||||
elif isinstance(error, commands.ArgumentParsingError):
|
elif isinstance(error, commands.ArgumentParsingError):
|
||||||
await ctx.send(error.__str__())
|
await ctx.send(error.__str__())
|
||||||
|
|
||||||
|
@ -92,9 +85,7 @@ class TuxBot(commands.AutoShardedBot):
|
||||||
await self.invoke(ctx)
|
await self.invoke(ctx)
|
||||||
|
|
||||||
async def on_message(self, message: discord.message):
|
async def on_message(self, message: discord.message):
|
||||||
if message.author.bot \
|
if message.author.bot or message.author.id in self.blacklist or message.guild.id in self.blacklist:
|
||||||
or message.author.id in self.blacklist \
|
|
||||||
or message.guild.id in self.blacklist:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
await self.process_commands(message)
|
await self.process_commands(message)
|
||||||
|
@ -118,11 +109,8 @@ class TuxBot(commands.AutoShardedBot):
|
||||||
@property
|
@property
|
||||||
def logs_webhook(self) -> discord.Webhook:
|
def logs_webhook(self) -> discord.Webhook:
|
||||||
logs_webhook = self.config.logs_webhook
|
logs_webhook = self.config.logs_webhook
|
||||||
webhook = discord.Webhook.partial(id=logs_webhook.get('id'),
|
webhook = discord.Webhook.partial(id=logs_webhook.get('id'), token=logs_webhook.get('token'), adapter=discord.AsyncWebhookAdapter(self.session))
|
||||||
token=logs_webhook.get('token'),
|
|
||||||
adapter=discord.AsyncWebhookAdapter(
|
|
||||||
self.session)
|
|
||||||
)
|
|
||||||
return webhook
|
return webhook
|
||||||
|
|
||||||
async def close(self):
|
async def close(self):
|
||||||
|
|
Loading…
Reference in a new issue