TwitchIO: Delete a single message in channel

1.3k views Asked by At

How can I delete a single message sent by a user using 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
1

There are 1 answers

0
Kai On BEST ANSWER

The question is older, but I'll answer it anyway.
Twitchio doesn't directly support this.
But you can delete individual messages in Twitch Chat, see the Twitch IRC documentation.
CLEARMSG (Twitch Commands)
You need the message ID for this. You get the ID in the message tags.
Message tags
Code example:

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}")

If you want to timeout someone, do the following:

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

Twitchio documentation Channel.timeout