discord py 使用参数
dicord py using an argument
我正在制作一个嵌入并尝试使用用户必须传入的参数,数字必须在范围 (1,13) 1 - 12 内,无法检查它是否在范围内,就像 return只有假
@client.command()
async def video(ctx, number):
if number == range(1,13):
await ctx.send('ready')
else:
await ctx.send(f'There are only {len(videos)} video(s) on the youtube channel')
不用担心视频变量,它只需要检查传入的数字是否在范围内。
比你
number
参数是一个字符串,您可以将其定义为 int,如下所示。
您还应该使用 in
进行比较,因为您不能将数字等同于一个范围。
这是固定的代码。
@client.command()
async def video(ctx, number: int):
if number in range(1,13):
await ctx.send('ready')
else:
await ctx.send(f'There are only {len(videos)} video(s) on the youtube channel')
我正在制作一个嵌入并尝试使用用户必须传入的参数,数字必须在范围 (1,13) 1 - 12 内,无法检查它是否在范围内,就像 return只有假
@client.command()
async def video(ctx, number):
if number == range(1,13):
await ctx.send('ready')
else:
await ctx.send(f'There are only {len(videos)} video(s) on the youtube channel')
不用担心视频变量,它只需要检查传入的数字是否在范围内。 比你
number
参数是一个字符串,您可以将其定义为 int,如下所示。
您还应该使用 in
进行比较,因为您不能将数字等同于一个范围。
这是固定的代码。
@client.command()
async def video(ctx, number: int):
if number in range(1,13):
await ctx.send('ready')
else:
await ctx.send(f'There are only {len(videos)} video(s) on the youtube channel')