generated from HoloTech/twitch-bot-template
(yarn): Add yarn module for one-off commands
This commit is contained in:
@@ -6,9 +6,10 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
async def twitch_setup(bot: "Bot"):
|
async def twitch_setup(bot: "Bot"):
|
||||||
# Import and run setup methods from each module
|
# Import and run setup methods from each module
|
||||||
from . import profiles, tracker, subathon, exec
|
from . import profiles, tracker, subathon, exec, yarn
|
||||||
|
|
||||||
await profiles.twitch_setup(bot)
|
await profiles.twitch_setup(bot)
|
||||||
await tracker.twitch_setup(bot)
|
await tracker.twitch_setup(bot)
|
||||||
await subathon.twitch_setup(bot)
|
await subathon.twitch_setup(bot)
|
||||||
await exec.twitch_setup(bot)
|
await exec.twitch_setup(bot)
|
||||||
|
await yarn.twitch_setup(bot)
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
async def twitch_setup(bot):
|
||||||
|
from .component import YarnComponent
|
||||||
|
await bot.add_component(YarnComponent(bot))
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import asyncio
|
||||||
|
|
||||||
|
import twitchio
|
||||||
|
from twitchio import PartialUser, Scopes, eventsub
|
||||||
|
from twitchio.ext import commands as cmds
|
||||||
|
|
||||||
|
from meta import Bot, Context
|
||||||
|
|
||||||
|
from . import logger
|
||||||
|
|
||||||
|
class YarnComponent(cmds.Component):
|
||||||
|
def __init__(self, bot: Bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
|
||||||
|
@cmds.Component.listener()
|
||||||
|
async def event_custom_redemption_add(self, payload: twitchio.ChannelPointsRedemptionAdd):
|
||||||
|
logger.info(f"Yarn got {payload!r}")
|
||||||
|
if payload.reward.title == 'pet lilac':
|
||||||
|
await payload.broadcaster.send_message("lilac PETPET", sender="1097964183")
|
||||||
Reference in New Issue
Block a user