python-3.x - 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 Chat 中删除个别消息,请参阅 Twitch IRC 文档。
CLEARMSG(Twitch 命令)
为此您需要消息 ID。您会在消息标签中获得 ID。
消息标签
代码示例:
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
推荐阅读
- git - 数据版本控制:管道参数中的绝对路径和项目路径?
- javascript - 全页站点:在每个循环中通过元素 onclick 导航
- python - 如何将变量 task_ids 传递给 Airflow 中的 xcom.pull?
- c# - 在 C# 中搜索二维对象数组
- discord - 是否可以通过命令显示我的 Discord 机器人当前连接了多少个语音通道?
- html - 如何显示淡入的svg元素?
- javascript - 滚动时突出显示菜单项不起作用
- haskell - 无法匹配预期类型 [Int] Haskell
- python - 使用 __new__ 无法执行的元类可以做什么?
- laravel - Laravel 8 的嵌套数据库播种