Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在if语句中阻止双重ups?_Python_Discord_Bots_Discord.py_Discord.py Rewrite - Fatal编程技术网

Python 如何在if语句中阻止双重ups?

Python 如何在if语句中阻止双重ups?,python,discord,bots,discord.py,discord.py-rewrite,Python,Discord,Bots,Discord.py,Discord.py Rewrite,我已经创建了一个bot,当用?give{arg}命令它时,它将输出{arg}已给定!。但是,我添加了一些特定的食物,它们将输出不同的信息(例如,拉面将输出拉面的图像),但是,因为从技术上讲,它仍然是一个arg,bot将输出两条信息,我如何对其进行编码,以便如果arg是特定食物之一,bot将只输出该特定信息 我的代码当前为: @client.command() async def give(ctx, arg, member: discord.Member = None, case_insensit

我已经创建了一个bot,当用?give{arg}命令它时,它将输出{arg}已给定!。但是,我添加了一些特定的食物,它们将输出不同的信息(例如,拉面将输出拉面的图像),但是,因为从技术上讲,它仍然是一个arg,bot将输出两条信息,我如何对其进行编码,以便如果arg是特定食物之一,bot将只输出该特定信息

我的代码当前为:

@client.command()
async def give(ctx, arg, member: discord.Member = None, case_insensitive=True):
    if arg == 'lumpia':
        if member:
            username = ctx.message.author.display_name
            name = member.display_name
            embed = discord.Embed(title=(f'{username} has given lumpia to {name}!'), description =('{|__|}\n( • . •)\n/ >You can use an 
if/elif
chain so that the evaluation starts at the first match:

if arg == 'lumpia':
    # do something
elif arg == 'ramen':
    # do something
else:
    # general case
@client.command()
async def give(ctx,arg,成员:discord.member=None,不区分大小写=True):
如果arg=='lumpia':
如果成员:
username=ctx.message.author.display\u name
name=member.display\u name

embed=discord.embed(title=(f'{username}已将lumpia赋予了{name}!'),description=('{124; | | | | | | |}}}\ n(•。•)\n/>您可以使用
if/elif
链,以便在第一次匹配时开始计算:

如果arg=='lumpia':
#做点什么
elif arg==“拉面”:
#做点什么
其他:
#一般情况

您可以使用
if/elif
链,以便在第一次匹配时开始评估:

如果arg=='lumpia':
#做点什么
elif arg==“拉面”:
#做点什么
其他:
#一般情况

这是否回答了您的问题?
arg!=“ramen”或“prawn”
如果arg不同于“ramen”或字符串“prawn”不为空,则表示
(并且“prawn”始终不为空)。在上面的链接问题中查看如何正确比较多个字符串这是否回答了您的问题?
arg!=“ramen”或“prawn”
表示
,如果arg不同于“ramen”或字符串“prawn”不为空(并且“prawn”始终不为空).查看上面的链接问题,了解如何正确比较多个字符串