【发布时间】:2021-01-25 05:24:32
【问题描述】:
@client.command()
@commands.is_owner()
async def nuke(ctx, channel_name):
existing_channel = discord.utils.get(guild.channels, name=channel_name)
if existing_channel is not None:
await clone(name=channel_name,reason="Has been nuked")
await existing_channel.delete()
else:
await ctx.send(f'No channel named **{channel_name}** was found')
我在 discord 上看到多个机器人已经可以通过 nuke 命令执行此操作,但我想自己学习如何执行此操作。问题是,我的机器人无法检测到我提到了一个频道(如附图所示)。我发现了一个类似的问题,关于“正确地核对一个频道”,但他们使用的是 cogs。帮助? This is the attached picture
【问题讨论】:
-
嗨。你想通过
channel_name传递什么?当您标记频道 #example-channel 并且它是指向该频道的可点击链接时,它实际上使用频道 ID 并且将是 。您的搜索将找不到。您必须输入nuke example-channel进行搜索才能找到任何内容 -
我遇到的问题是,无论我输入什么,我仍然不会收到错误消息????我曾尝试使用
nuke example-channel,但最终还是没有用。有没有办法让机器人改用可点击的#example-channel?
标签: python discord discord.py