【问题标题】:TwitchIO: Delete a single message in channelTwitchIO:删除频道中的单个消息
【发布时间】:2021-02-05 11:33:06
【问题描述】:

如何删除用户使用 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

【问题讨论】:

    标签: python-3.x twitch-api


    【解决方案1】:

    这个问题比较老,但我还是会回答。
    Twitchio 不直接支持这一点。
    但您可以在 Twitch Chat 中删除个别消息,请参阅 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

    【讨论】:

      猜你喜欢
      • 2021-02-18
      • 2019-06-13
      • 2022-01-12
      • 2020-10-01
      • 1970-01-01
      • 2020-11-08
      • 2018-05-16
      • 1970-01-01
      • 2017-09-11
      相关资源
      最近更新 更多