Discord.py selfbot:如何在发送后立即删除邮件?

时间:2018-05-23 18:09:33

标签: python discord discord.py discord.py-rewrite

如果它发送消息标记所有人,它怎么能这样做呢?它会立即删除消息?

以下是代码:

import discord
from discord.ext import commands

class MentionBomb:
def __init__(self, bot):
    self.bot = bot

@commands.command(pass_context=True)
async def mbomb(self, ctx):
    await ctx.message.delete()

    messages = []
    msg = ""

    for member in ctx.message.channel.members:
        if len(msg) >= 1980:
            messages.append(msg)
            msg = ""

        msg += member.mention + "\n"

    if len(msg) >= 1:
        messages.append(msg)

    for message in messages:
        await ctx.send(message)

def setup(bot):
    bot.add_cog(MentionBomb(bot))

1 个答案:

答案 0 :(得分:0)

send返回一个表示刚刚发送的消息的对象。该Message对象具有delete协程。

for message in messages:
        sent = await ctx.send(message)
        await sent.delete()