我的代码:
@commands.Cog.listener()
async def on_command(self, ctx):
channel = client.get_channel(int(772906069885321236))
await channel.send(discord.Object(id=772906069885321236), f"{ctx.guild.name} {ctx.author} {ctx.message.clean_content}")
我尝试使用意图,但我似乎也无法弄清楚它们
答案 0 :(得分:0)
根据docs,如果找不到指定的频道,get_channel
返回None
。
答案 1 :(得分:0)
get_channel
返回None
。您可以添加一些错误处理来解决此问题 if 对您正在构建的项目有意义。
@commands.Cog.listener()
async def on_command(self, ctx):
try:
channel = client.get_channel(int(772906069885321236))
await channel.send(discord.Object(id=772906069885321236),
f"{ctx.guild.name} {ctx.author} {ctx.message.clean_content}")
except:
print("Channel not found")