我的 nuke 命令有问题,它应该删除当前频道并克隆它,清除所有消息。问题是它根本不工作并且没有给出任何错误!
代码
@client.command()
@commands.has_permissions(administrator=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}"
)
nuke_ch = discord.utils.get(ctx.guild.channels, name=ctx.channel.name)
new_ch = await nuke_ch.clone(reason="Being nuked and remade!")
await nuke_ch.delete()
sendem = new_ch.send(embed=embed)
await asyncio.sleep(3)
sendem.delete()
如果您有解决方案,请回答此问题。提前致谢。
答案 0 :(得分:0)
请记住还要请求 nuke_ch
作为命令中的参数。您只需使用 ctx
,仅此而已。
这是我曾经使用过的 nuke
命令:
@client.command()
@commands.has_permissions(administrator=True)
async def nuke(ctx, channel_name):
channel_id = int(''.join(i for i in channel_name if i.isdigit()))
existing_channel = client.get_channel(channel_id) # Get channel ID
if existing_channel:
await ctx.send("**This channel will be nuked in X seconds.**")
await asyncio.sleep(YourValue) # Can be removed
await existing_channel.delete() # Deletes the old channel
existing = await existing_channel.clone() # Clones the channel again
await existing.send("**This channel was nuked/re-created!**")
else:
await ctx.send(f'**No channel named `{channel_name}` was found.**')
我们做了什么?