我已经在Discord机器人中执行了nuke命令,但是它有2个问题。首先是如何将消息发送到刚刚创建的频道,其次是如何将频道设置为与“原始”频道相同的位置。
这是我的代码:
# nuke
@client.command()
@commands.has_permissions(ban_members=True)
async def nuke(ctx):
embed = discord.Embed(
colour=discord.Colour.blue,
title=f":boom: Channel ({ctx.channel.name}) has been nuked :boom:",
description=f"Nuked by: {ctx.author.name}#{ctx.author.discriminator}"
)
embed.set_footer(text=f"{ctx.guild.name} • {datetime.strftime(datetime.now(), '%d.%m.%Y at %I:%M %p')}")
await ctx.channel.delete(reason="nuke")
await ctx.channel.clone(reason="nuke")
await ctx.send(embed=embed)
您可以将克隆的通道存储在变量中:
# nuke
@client.command()
@commands.has_permissions(ban_members=True)
async def nuke(ctx):
embed = discord.Embed(
colour=discord.Colour.blue,
title=f":boom: Channel ({ctx.channel.name}) has been nuked :boom:",
description=f"Nuked by: {ctx.author.name}#{ctx.author.discriminator}"
)
embed.set_footer(text=f"{ctx.guild.name} • {datetime.strftime(datetime.now(), '%d.%m.%Y at %I:%M %p')}")
await ctx.channel.delete(reason="nuke")
channel = await ctx.channel.clone(reason="nuke")
await channel.send(embed=embed)
通道应该在与原始通道相同的位置上创建,否则:
pos = ctx.channel.position
await ctx.channel.delete()
channel = await ctx.channel.clone()
await channel.edit(position=pos)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句