Fix code style issues with Black

This commit is contained in:
Lint Action
2021-09-05 21:34:20 +00:00
parent a23dae8604
commit 7513c2138f
108 changed files with 5369 additions and 4858 deletions

View File

@@ -7,7 +7,7 @@ from discord.ext import commands
intents = discord.Intents(guilds=True, messages=True, members=True)
bot = commands.Bot('!', intents=intents)
bot = commands.Bot("!", intents=intents)
@bot.command()
@@ -28,14 +28,16 @@ async def userinfo(ctx: commands.Context, user: discord.User):
user_id = user.id
username = user.name
avatar = user.avatar.url
await ctx.send(f'User found: {user_id} -- {username}\n{avatar}')
await ctx.send(f"User found: {user_id} -- {username}\n{avatar}")
@userinfo.error
async def userinfo_error(ctx: commands.Context, error: commands.CommandError):
# if the conversion above fails for any reason, it will raise `commands.BadArgument`
# so we handle this in this error handler:
if isinstance(error, commands.BadArgument):
return await ctx.send('Couldn\'t find that user.')
return await ctx.send("Couldn't find that user.")
# Custom Converter here
class ChannelOrMemberConverter(commands.Converter):
@@ -72,15 +74,15 @@ class ChannelOrMemberConverter(commands.Converter):
raise commands.BadArgument(f'No Member or TextChannel could be converted from "{argument}"')
@bot.command()
async def notify(ctx: commands.Context, target: ChannelOrMemberConverter):
# This command signature utilises the custom converter written above
# What will happen during command invocation is that the `target` above will be passed to
# the `argument` parameter of the `ChannelOrMemberConverter.convert` method and
# the `argument` parameter of the `ChannelOrMemberConverter.convert` method and
# the conversion will go through the process defined there.
await target.send(f'Hello, {target.name}!')
await target.send(f"Hello, {target.name}!")
@bot.command()
async def ignore(ctx: commands.Context, target: typing.Union[discord.Member, discord.TextChannel]):
@@ -94,9 +96,10 @@ async def ignore(ctx: commands.Context, target: typing.Union[discord.Member, dis
# To check the resulting type, `isinstance` is used
if isinstance(target, discord.Member):
await ctx.send(f'Member found: {target.mention}, adding them to the ignore list.')
elif isinstance(target, discord.TextChannel): # this could be an `else` but for completeness' sake.
await ctx.send(f'Channel found: {target.mention}, adding it to the ignore list.')
await ctx.send(f"Member found: {target.mention}, adding them to the ignore list.")
elif isinstance(target, discord.TextChannel): # this could be an `else` but for completeness' sake.
await ctx.send(f"Channel found: {target.mention}, adding it to the ignore list.")
# Built-in type converters.
@bot.command()
@@ -109,4 +112,5 @@ async def multiply(ctx: commands.Context, number: int, maybe: bool):
return await ctx.send(number * 2)
await ctx.send(number * 5)
bot.run('token')
bot.run("token")