Python 3.x 我要数控!用于机器人的nuke#频道删除所有消息(不频道,仅频道上的消息)
谁有密码Python 3.x 我要数控!用于机器人的nuke#频道删除所有消息(不频道,仅频道上的消息),python-3.x,discord.py,Python 3.x,Discord.py,谁有密码 async def nuke(ctx, channel: discord.TextChannel = None): if channel == None: await ctx.send("You did not mention a channel!") return nuke_channel = discord.utils.get(ctx.guild.channels, name=channel.name)
async def nuke(ctx, channel: discord.TextChannel = None):
if channel == None:
await ctx.send("You did not mention a channel!")
return
nuke_channel = discord.utils.get(ctx.guild.channels, name=channel.name)
if nuke_channel is not None:
new_channel = await nuke_channel.clone(reason="Has been Nuked!")
await nuke_channel.delete()
await new_channel.send("THIS CHANNEL HAS BEEN NUKED!")
await ctx.send("Nuked the Channel sucessfully!")
else:
await ctx.send(f"No channel named {channel.name} was found!")```
您必须使用
discord.TextChannel.purge()
函数
channel#discord.TextChannel对象(最有可能是参数)
等待通道清除(限制=100)#清除一定数量的消息。你可以选择
请参阅
purge()
函数如果您已经拥有频道,为什么要discord.utils.get()
再次访问该频道?因此,无论出于何种原因,删除邮件都有14天的限制,如下所述。最好是复制有关频道的所有数据(名称、频道组、频道描述、角色设置),完全删除现有频道,然后使用删除前收集的信息重新创建频道。我不希望清除只写nc!nuke和bot删除通道中的所有消息删除通道中的所有消息正在清除@Alvesok@Alvesok一次最多只能删除100封邮件。@Dominik您可以删除所有邮件。它们只需要不到14天就可以播放。@12944qwerty一个频道在一个小时内就可以收到2000多条信息。你的命令没用。