首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >任务不删除消息,discord.py

任务不删除消息,discord.py
EN

Stack Overflow用户
提问于 2021-11-02 10:45:25
回答 1查看 31关注 0票数 1

所以基本上这是我为我的服务器创建的一个lootbox,它应该自动删除。但当我醒来时,我会检查我的频道,看到4-5个消息,而不是1个!有什么帮助吗?- edit -我应该提一下,当我使x= 30分钟,删除时间为29分钟时,这很好用。

代码语言:javascript
复制
x = 180
@tasks.loop(minutes=x)
async def send():
    open('acceptloot.txt', 'w').close()
    response = "Frag has sent supplies into the field, if you're lucky you can get some!"
    channel = bot.get_channel(903563274807808040)
    await channel.send(file=discord.File('lootbox.png'), delete_after=10650)
    message = await channel.send(response, delete_after=10750)
    await message.add_reaction('✅')

@send.before_loop
async def before():
    await bot.wait_until_ready()

send.start()
EN

回答 1

Stack Overflow用户

发布于 2021-11-02 10:55:48

你可以尝试老方法,不需要"delete_after=":

代码语言:javascript
复制
message = 'your message' # your message
msg = await bot.send(message) # sends message
await asyncio.sleep(5) # wait 5 seconds  
await msg.delete() # delete the message
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69809087

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档