Fix type errors in all examples

This commit is contained in:
Rapptz
2025-08-16 05:21:19 -04:00
parent 7e2ca02fd1
commit 4f539b710f
26 changed files with 124 additions and 16 deletions

View File

@ -83,8 +83,14 @@ class ChannelOrMemberConverter(commands.Converter):
raise commands.BadArgument(f'No Member or TextChannel could be converted from "{argument}"')
# Make it so the converter is friendly to type checkers
# The first parameter of typing.Annotated is the type we tell the type checker
# The second parameter is what converter the library uses
ChannelOrMember = typing.Annotated[typing.Union[discord.Member, discord.TextChannel], ChannelOrMemberConverter]
@bot.command()
async def notify(ctx: commands.Context, target: ChannelOrMemberConverter):
async def notify(ctx: commands.Context, target: ChannelOrMember):
# 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
@ -118,8 +124,8 @@ async def multiply(ctx: commands.Context, number: int, maybe: bool):
# See: https://discordpy.readthedocs.io/en/latest/ext/commands/commands.html#bool
if maybe is True:
return await ctx.send(number * 2)
await ctx.send(number * 5)
return await ctx.send(str(number * 2))
await ctx.send(str(number * 5))
bot.run('token')