Python 如何使discord机器人以不同的图像/响应响应命令?
例如,如果用户键入类似于Python 如何使discord机器人以不同的图像/响应响应命令?,python,discord,discord.py,bots,Python,Discord,Discord.py,Bots,例如,如果用户键入类似于的命令!minecraft对于机器人,它将以一个图像响应,如果我再次执行该命令,它将以另一个图像响应。好的,您可以创建类似图像/短语列表的内容,并每次随机选择其中一个: import random @bot.command async def hello(ctx): # now create a list of images/ phrases/ ... phrase_list = ["Hello!", "Hi!",
的命令!minecraft
对于机器人,它将以一个图像响应,如果我再次执行该命令,它将以另一个图像响应。好的,您可以创建类似图像/短语列表的内容,并每次随机选择其中一个:
import random
@bot.command
async def hello(ctx):
# now create a list of images/ phrases/ ...
phrase_list = ["Hello!", "Hi!", "Good morning!"]
phrase = random.choice(phrase_list)
await ctx.send(phrase)
下次请问一个更准确的问题;) 欢迎来到StackOverflow。请包括您的代码、方法和您面临的错误。你也可以看看——这确实是可能的。