如果它发送消息标记所有人,它怎么能这样做呢?它会立即删除消息?
以下是代码:
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))
答案 0 :(得分:0)
send
返回一个表示刚刚发送的消息的对象。该Message
对象具有delete
协程。
for message in messages:
sent = await ctx.send(message)
await sent.delete()