我想用新的隨機發生器功能擴展我的 Discord Bot。我總是想手動輸入值/變數,例如:
Input: !random text1 text2 text3 Output: The result is "text2"
我需要 Discord.py (Python) 中的所有內容,并且沒有斜杠 (/) 命令。我試過了:
@bot.command()
async def r(ctx, str, name1: str, name2):
list = [str(name1), str(name2)];
embed = discord.Embed(
colour=0xc81f9f,
title="Rating",
description=f"{ctx.author.mention} {random.choice(list)} is your rating"
)
await ctx.send(embed=embed)
uj5u.com熱心網友回復:
您可以使用to grab arguments而不是手動執行name1,name2*args
@bot.command()
async def r(ctx, *args):
embed = discord.Embed(
colour=0xc81f9f,
title="Rating",
description=f"{ctx.author.mention} {random.choice(args)} is your rating"
)
await ctx.send(embed=embed)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/533717.html
上一篇:之后從函式輸入和文本中獲取變數
下一篇:JS通過變數呼叫ID
