
Self.IRC = IRC - IRC is received from _IRC() and is an instance of Prefix is the part of the message at the beginning that let’s the bot know that the message is meant for it. Super()._init_(prefix='!) - You have to call ’s init function which only has one argument. run ()Ĭlass M圜ommands(Commands.Cog): - If you want to create your own commands, TwitchPy requires you to create aĬlass that inherits from. add_cogs ( my_commands ) # don't forget to add the cog to the bot bot. Client ( ** login ) my_commands = M圜ommands ( bot. create () # decorator used to create the command async def ping ( self, ctx ): # the function must take one argument: chat await self. IRC = IRC # obtained from TwitchBot.Client so we can interact with chat. _init_ ( prefix = '!' ) # calling Commands.Cog's init is required! self. Cog ): # make sure to inherit Commands.Cog def _init_ ( self, IRC ): super (). From TwitchPy import TwitchBot, Commands class M圜ommands ( Commands.
