Sorry for what’s probably a really stupid question but new to all this, trying to teach myself and been playing with the following script for 4 hours…
import discord
import requests
import json
client = discord.Client()
# Replace YOUR_TWITCH_CLIENT_ID with your actual Twitch client ID
headers = {'Client-ID': 'TWITCH APPLICATION ID'}
# List of usernames (Twitch Usernames to Track)
usernames = ['KYRR4pt0r']
while True:
for username in usernames:
# Get the user's ID from their username
url = f'https://api.twitch.tv/helix/users?login={username}'
response = requests.get(url, headers=headers)
data = json.loads(response.text)
try:
print(data)
print(response)
user_id = data['data'][0]['id']
except IndexError:
print(f"{username} not found")
continue
# Check if the user is currently streaming
url = f'https://api.twitch.tv/helix/streams?user_id={user_id}'
response = requests.get(url, headers=headers)
data = json.loads(response.text)
if data['data']:
print(f'{username} is online!')
else:
print(f'{username} is offline.')
# Check the stream status every 60 seconds
time.sleep(60)
client.run("DISCORD BOT ID")