Discord.py不解开自己的bot';s消息

Discord.py不解开自己的bot';s消息,discord,discord.py,Discord,Discord.py,我的测试代码是 @bot.command(name='test') async def test(ctx): message = await ctx.send('test') channel = ctx.channel message = await channel.fetch_message(message.id) await message.pin() await message.unpin() 机器人会锁定消息,但不会解除锁定。我测试了代码,对我来

我的测试代码是

@bot.command(name='test')
async def test(ctx):
    message = await ctx.send('test')
    channel = ctx.channel
    message = await channel.fetch_message(message.id)
    await message.pin()
    await message.unpin()

机器人会锁定消息,但不会解除锁定。

我测试了代码,对我来说效果很好


注意-Discord仅显示有人已锁定该消息的消息,但Discord不显示是否有人已取消锁定该消息,您需要在锁定的消息中检查它。

我现在测试了它,它也可以工作。我不知道上次它为什么不起作用,但在我发布问题之前,通道中的代码是
channel=message.channel
。您应该注意的是,当您调用
wait message.pin()
,成功地将该命令发送到discord时,将返回。它不能确保命令完成。因此,您可能遇到争用条件,其中discord服务器在pin之前接收到
unpin()
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix = '!')

@bot.event
async def on_ready():
    print('Logged successfully!')

@bot.command()
async def test(ctx):
    message = await ctx.send('test')
    await message.pin()
    await message.unpin()

bot.run('BOT_TOKEN_HERE')