Skip to content

Interacting_With_Chat_In_Commands

sharkbound edited this page Sep 3, 2022 · 8 revisions

Index

  • [Sending Messages To Chat](#Sending Messages To Chat)

Sending Messages To Chat

  • [Basic usage of msg.reply()](#Basic usage of msg.reply())
  • [Sending Message as a Twitch Reply msg.reply()](#Sending Message as a Twitch Reply msg.reply())

Basic usage of msg.reply()

msg.reply() is used to send messages to twitch chat the command was called from

example:

from twitchbot import Message, Command


@Command(name='basic')
async def cmd_test(msg: Message):
    # note: msg.mention is the message authors name prefixed with an @
    # ex: johndoe: !basic
    # will say this to chat: `hello there @johndoe!`
    await msg.reply(f'hello there {msg.mention}!')

This will send the follow message to twitch chat:

hello there @johndoe!

Sending Message as a Twitch Reply msg.reply()

Twitch Replies reference the original message via a small clickable button next to the message in twitch chat.

This can be useful when the command is often being called from a more active chat

example:

from twitchbot import Message, Command


@Command(name='astwitchreply')
async def cmd_test(msg: Message):
    await msg.reply('check me in twitch chat to see who called me!', as_twitch_reply=True)    

example: BACK TO INDEX

Clone this wiki locally