[英]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.