【问题标题】:How can i remove message information in discord.py?如何删除 discord.py 中的消息信息?
【发布时间】:2021-01-21 03:42:05
【问题描述】:

代码:

@bot.command()
async def perc(ctx,arg):
percList = []

for c in arg:
    arg3 = str(c)
    percList.append(arg3)

listtostr = ''.join([str(elem) for elem in percList])

perc = 0
perctext = await ctx.send(str(listtostr) + str(perc) + "%")

while perc < 100:
    perc += random.randint(1,3) 
    time.sleep(0.1)

    await perctext.edit(content = str(perctext) + str(perc) + "%")

    if perc == 100 or perc >= 100:
        break

输出: author= flags=>16%

【问题讨论】:

    标签: python discord.py


    【解决方案1】:

    你需要使用Message.content

    @bot.command()
    async def perc(ctx,arg):
        percList = []
    
        for c in arg:
            arg3 = str(c)
            percList.append(arg3)
    
        listtostr = ''.join([str(elem) for elem in percList])
    
        perc = 0
        perctext = await ctx.send(str(listtostr) + str(perc) + "%")
    
        while perc < 100:
            perc += random.randint(1,3) 
            time.sleep(0.1)
            await perctext.edit(content = perctext.content + str(perc) + "%")
    
            if perc == 100 or perc >= 100:
                break
    

    【讨论】:

      猜你喜欢
      • 2018-06-29
      • 2018-04-29
      • 2021-09-08
      • 1970-01-01
      • 2021-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-24
      相关资源
      最近更新 更多