aboutsummaryrefslogtreecommitdiff
path: root/discord/ext/commands/bot.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-04-04 04:40:19 -0400
committerRapptz <[email protected]>2021-04-04 07:03:53 -0400
commit9d39b135f4f84239787b0901d06a4f370a82d4bb (patch)
tree8826845cfd47eafa5c9d2ef1fcbedd36382714f4 /discord/ext/commands/bot.py
parentBump minimum Python version to 3.8 (diff)
downloaddiscord.py-9d39b135f4f84239787b0901d06a4f370a82d4bb.tar.xz
discord.py-9d39b135f4f84239787b0901d06a4f370a82d4bb.zip
Modernize code to use f-strings
This also removes the encoding on the top, since Python 3 does it by default. It also changes some methods to use `yield from`.
Diffstat (limited to 'discord/ext/commands/bot.py')
-rw-r--r--discord/ext/commands/bot.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py
index ee0308e2..503aa266 100644
--- a/discord/ext/commands/bot.py
+++ b/discord/ext/commands/bot.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
"""
The MIT License (MIT)
@@ -46,7 +44,7 @@ def when_mentioned(bot, msg):
These are meant to be passed into the :attr:`.Bot.command_prefix` attribute.
"""
- return [bot.user.mention + ' ', '<@!%s> ' % bot.user.id]
+ return [f'<@{bot.user.id}> ', f'<@!{bot.user.id}> ']
def when_mentioned_or(*prefixes):
"""A callable that implements when mentioned or other prefixes provided.
@@ -114,7 +112,7 @@ class BotBase(GroupMixin):
raise TypeError('Both owner_id and owner_ids are set.')
if self.owner_ids and not isinstance(self.owner_ids, collections.abc.Collection):
- raise TypeError('owner_ids must be a collection not {0.__class__!r}'.format(self.owner_ids))
+ raise TypeError(f'owner_ids must be a collection not {self.owner_ids.__class__!r}')
if options.pop('self_bot', False):
self._skip_check = lambda x, y: x != y
@@ -169,7 +167,7 @@ class BotBase(GroupMixin):
if cog and Cog._get_overridden_method(cog.cog_command_error) is not None:
return
- print('Ignoring exception in command {}:'.format(context.command), file=sys.stderr)
+ print(f'Ignoring exception in command {context.command}:', file=sys.stderr)
traceback.print_exception(type(exception), exception, exception.__traceback__, file=sys.stderr)
# global check registration
@@ -944,7 +942,7 @@ class BotBase(GroupMixin):
else:
self.dispatch('command_completion', ctx)
elif ctx.invoked_with:
- exc = errors.CommandNotFound('Command "{}" is not found'.format(ctx.invoked_with))
+ exc = errors.CommandNotFound(f'Command "{ctx.invoked_with}" is not found')
self.dispatch('command_error', ctx, exc)
async def process_commands(self, message):