Skip to the content.

Changelog - Version 3.6 (2024-04-01)

Added

@commands.command(name='clip')
    async def clip_command(self, ctx):
        try:
            if not stream_online:
                await ctx.send("Sorry, I can only create clips while the stream is online.")
                return

            # Headers & Params for TwitchAPI
            headers = {
                "Client-ID": TWITCH_API_CLIENT_ID,
                "Authorization": f"Bearer {CHANNEL_AUTH}"
            }
            params = {
                "broadcaster_id": CHANNEL_ID
            }
            clip_response = requests.post('https://api.twitch.tv/helix/clips', headers=headers, params=params)
            if clip_response.status_code == 200:
                clip_data = clip_response.json()
                clip_id = clip_data['data'][0]['id']
                clip_url = f"http://clips.twitch.tv/{clip_id}"
                await ctx.send(f"{ctx.author.name} created a clip: {clip_url}")

                # Create a stream marker
                marker_description = f"Clip created by {ctx.author.name}"
                marker_payload = {
                    "user_id": CHANNEL_ID,
                    "description": marker_description
                }
                marker_headers = {
                    "Client-ID": TWITCH_API_CLIENT_ID,
                    "Authorization": f"Bearer {CHANNEL_AUTH}",
                    "Content-Type": "application/json"
                }
                marker_response = requests.post('https://api.twitch.tv/helix/streams/markers', headers=marker_headers, json=marker_payload)
                if marker_response.status_code == 200:
                    marker_data = marker_response.json()
                    marker_created_at = marker_data['data'][0]['created_at']
                    twitch_logger.info(f"A stream marker was created at {marker_created_at} with description: {marker_description}.")
                else:
                    twitch_logger.info("Failed to create a stream marker.")

            else:
                await ctx.send(f"Failed to create clip.")
                twitch_logger.error(f"Status code: {clip_response.status_code}")
        except requests.exceptions.RequestException as e:
            twitch_logger.error(f"Error making clip: {e}")
            await ctx.send("An error occurred while making the request. Please try again later.")
@commands.command(name='marker')
    async def marker_command(self, ctx, *, description: str):
        if is_mod_or_broadcaster(ctx.author):
            if description:
                marker_description = description
            else:
                marker_description = f"Marker made by {ctx.author.name}"
            try:
                marker_payload = {
                    "user_id": CHANNEL_ID,
                    "description": marker_description
                }
                marker_headers = {
                    "Client-ID": TWITCH_API_CLIENT_ID,
                    "Authorization": f"Bearer {CHANNEL_AUTH}",
                    "Content-Type": "application/json"
                }
                marker_response = requests.post('https://api.twitch.tv/helix/streams/markers', headers=marker_headers, json=marker_payload)
                if marker_response.status_code == 200:
                    marker_data = marker_response.json()
                    marker_created_at = marker_data['data'][0]['created_at']
                    await ctx.send(f"A stream marker was created at {marker_created_at} with description: {marker_description}.")
                else:
                    await ctx.send("Failed to create a stream marker.")
            except requests.exceptions.RequestException as e:
                twitch_logger.error(f"Error creating stream marker: {e}")
                await ctx.send("An error occurred while making the request. Please try again later.")
        else:
            await ctx.send(f"You must be a moderator or the broadcaster to use this command.")
@commands.command(name='subscription', aliases=['mysub'])
    async def subscription_command(self, ctx):
        try:
            # Headers & Params for Twitch API
            user_id = ctx.author.id
            headers = {
                "Client-ID": TWITCH_API_CLIENT_ID,
                "Authorization": f"Bearer {CHANNEL_AUTH}"
            }
            params = {
                "broadcaster_id": CHANNEL_ID,
                "user_id": user_id
            }
            tier_mapping = {
                "1000": "Tier 1",
                "2000": "Tier 2",
                "3000": "Tier 3"
            }
            subscription_response = requests.get('https://api.twitch.tv/helix/subscriptions', headers=headers, params=params)
            if subscription_response.status_code == 200:
                subscription_data = subscription_response.json()
                subscriptions = subscription_data.get('data', [])

                if subscriptions:
                    # Iterate over each subscription
                    for subscription in subscriptions:
                        user_name = subscription['user_name']
                        tier = subscription['tier']
                        is_gift = subscription['is_gift']
                        gifter_name = subscription['gifter_name'] if is_gift else None
                        tier_name = tier_mapping.get(tier, tier)

                        # Prepare message based on subscription status
                        if is_gift:
                            await ctx.send(f"{user_name}, your gift subscription from {gifter_name} is {tier_name}.")
                        else:
                            await ctx.send(f"{user_name}, you are currently subscribed at {tier_name}.")
                else:
                    # If no subscriptions found for the provided user ID
                    await ctx.send(f"You are currently not subscribed to {CHANNEL_NAME}, you can subscribe here: https://subs.twitch.tv/{CHANNEL_NAME}")
            else:
                await ctx.send(f"Failed to retrieve subscription information. Please try again later.")
                twitch_logger.error(f"Failed to retrieve subscription information. Status code: {subscription_response.status_code}")

        except requests.exceptions.RequestException as e:
            twitch_logger.error(f"Error retrieving subscription information: {e}")
            await ctx.send("An error occurred while making the request. Please try again later.")

Thank you for your feedback and support!

As always, your feedback is appreciated. Please report any issues, bugs, or suggestions in the #ticket-info channel on our Discord server. You can also submit feedback and bug reports directly on our website: https://botofthespecter.com/feedback.php