[英]How do i make a command that make my bot leave from the server (discord.py)
[英]How do I make my Discord.py bot pick a random "line" from a .txt file in the same folder as my main code?
我正在制作一个整体有趣的机器人,我希望它选择一种已写入 .txt 文件的随机颜色。 请在此平台或 Discord 上提供帮助。 我的 Discord 用户名是:RelaxedNerd#3072。
将它们设置为变量并导入这样的随机数会更容易
import random
@client.command()
async def color(ctx):
responses = ['red',
'blue',
'green',
'purple',
'Add more',]
await ctx.send(f'Color: {random.choice(responses)}')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.