我想要这样,如果var StoreNames4包含单词“ Closed”,则它将不会发送嵌入内容,而是继续执行脚本的下一部分。我不确定该怎么做,我尝试了多种方法,但它似乎每次都发送。
# Discord Embed Setup 4
embed = Embed(
description="A new "+ItemTitles+" is available!",
color=0x0d0d22,
timestamp='now' # sets the timestamp to current time
)
embed.set_title(title="**"+ItemTitles+"**")
embed.add_field(name="**Release:**", value=Dates, inline=True)
embed.add_field(name="**ColorWay:**", value=ColorWays, inline=True)
embed.add_field(name="**Retail:**", value=Retails, inline=True)
embed.add_field(name="**PID:**", value=PIDs, inline=True)
embed.add_field(name="**Store Name:**", value=StoreNames4, inline=True)
embed.add_field(name="**Close Date:**", value=CloseDates4, inline=True)
embed.add_field(name="**Type:**", value=Types4, inline=True)
embed.add_field(name="**Country:**", value=Countries4, inline=True)
embed.set_footer(text='TEST', icon_url='ICONURL')
embed.set_image(image.get_attribute('src'))
await ctx.send(embed=embed)
print("Embed sent to discord!")
答案 0 :(得分:0)
使用StoreNames4
检查if StoreNames4 != "Closed": ...
是否未“关闭”,将您的嵌入代码放入该if语句中。
答案 1 :(得分:0)
如果StoreNames4
变量为'Closed',如果您不想发送嵌入,则可以执行以下操作:
if 'Closed' not in StoreNames4:
embed = Embed(
description="A new "+ItemTitles+" is available!",
color=0x0d0d22,
timestamp='now' # sets the timestamp to current time
)
embed.set_title(title="**"+ItemTitles+"**")
embed.add_field(name="**Release:**", value=Dates, inline=True)
embed.add_field(name="**ColorWay:**", value=ColorWays, inline=True)
embed.add_field(name="**Retail:**", value=Retails, inline=True)
embed.add_field(name="**PID:**", value=PIDs, inline=True)
embed.add_field(name="**Store Name:**", value=StoreNames4, inline=True)
embed.add_field(name="**Close Date:**", value=CloseDates4, inline=True)
embed.add_field(name="**Type:**", value=Types4, inline=True)
embed.add_field(name="**Country:**", value=Countries4, inline=True)
embed.set_footer(text='TEST', icon_url='ICONURL')
embed.set_image(image.get_attribute('src'))
await ctx.send(embed=embed)
print("Embed sent to discord!")
答案 2 :(得分:0)
如果我没错,您希望仅在变量StoreNames4
中没有单词Closed
的情况下发送嵌入内容。如果是这样,您可以使用此if语句检查StoreNames4
中是否没有'closed':if "Closed" not in StoreNames4
if "Closed" not in StoreNames4:
embed = Embed(
description="A new "+ItemTitles+" is available!",
color=0x0d0d22,
timestamp='now' # sets the timestamp to current time
)
embed.set_title(title="**"+ItemTitles+"**")
embed.add_field(name="**Release:**", value=Dates, inline=True)
embed.add_field(name="**ColorWay:**", value=ColorWays, inline=True)
embed.add_field(name="**Retail:**", value=Retails, inline=True)
embed.add_field(name="**PID:**", value=PIDs, inline=True)
embed.add_field(name="**Store Name:**", value=StoreNames4, inline=True)
embed.add_field(name="**Close Date:**", value=CloseDates4, inline=True)
embed.add_field(name="**Type:**", value=Types4, inline=True)
embed.add_field(name="**Country:**", value=Countries4, inline=True)
embed.set_footer(text='TEST', icon_url='ICONURL')
embed.set_image(image.get_attribute('src'))
await ctx.send(embed=embed)
print("Embed sent to discord!")
这是假设StoreNames4
已分配给字符串