Skip to content

Writing Commands

Here you can find a quickstart guide on how to write your own commands for your Twitch bot.

Writing a command

To write your own commands on the src/commands.py file, you can follow the !ping command example below:

src/commands.py
from twitchio.ext import commands
class BotCommands(commands.Cog):
def __init__(self, bot):
self.bot = bot
# Command to respond to the !ping message
@commands.command(name="ping")
async def cmd_ping(self, ctx: commands.Context):
await ctx.send(f"pong! 🏓") # Reply on the chat with a pong
def setup(bot):
bot.add_cog(BotCommands(bot))