【发布时间】:2020-08-23 18:40:44
【问题描述】:
您好,我正在制作一个机器人来创建排行榜,这是代码
@bot.command(pass_context=True)
async def on(ctx):
await ctx.send("How many total teams are there?")
t = await get_input_of_type(int, ctx)
totalteam = 0
while totalteam <= t:
await ctx.send("Enter team name :")
teamname1 = await get_input_of_type(str, ctx)
await ctx.send("How many kills did they get?")
firstnum1 = await get_input_of_type(int, ctx)
await ctx.send("How much Position points did they score?")
secondnum1 = await get_input_of_type(int, ctx)
totalteam -=1
await ctx.channel.send("**__Today's Result:__**")
await ctx.channel.send("Format: Team Name/Kills/Position Points/Total Points")
await ctx.send(f"{teamname1} | {firstnum1} | {secondnum1} = {firstnum1+secondnum1}")
此命令使用户可以选择要创建多少个团队来创建排行榜。 整个团队的循环有效,但我也想要一些能在循环中显示结果的东西。 我希望它应该发送用户输入的每个团队的总分。现在它只发送第一个入口点。
【问题讨论】:
-
你希望它输出什么?输入预期结果?
-
get_input_of_type的功能是什么? -
sum = 0 以上 while 循环比 sum=sum+secondnum1+kills 可以工作,而不是输出 sum。
标签: python discord discord.py