TwitchIO:删除频道中的一条消息

问题描述

如何删除用户使用TwitchIO发送的单个消息?

@bot.event
async def event_message(ctx):
    await ctx.content.delete() # Does not work
    await ctx.content.remove() # Does not work
    await ctx.channel.timeout(ctx.author,1) # Does not work

解决方法

这个问题比较老,但我还是会回答。
Twitchio不直接支持此功能。
但是您可以在Twitch聊天中删除单个消息,请参阅Twitch IRC文档。
CLEARMSG (Twitch Commands)
您需要为此的消息ID。您可以在消息标签中获得ID。
Message tags
代码示例:

async def event_message(message):
    if not message.author.name == self.bot.nick:
        message_id = message.tags['id']
        await message.channel.send(f"/delete {message_id}")

如果您想使某人超时,请执行以下操作:

await message.channel.timeout(message.author.name,120,f"reason")

Twitchio文档Channel.timeout

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...