import discord import os import asyncio import requests intents = discord.Intents.default() client = discord.Client(intents=intents) token = 'dein_Discord_Token' channel_id = deine_Kanal_id webhook_url1 = 'http://homeassistant.local:8123/api/webhook/dein_Webhook_1' webhook_url2 = 'http://homeassistant.local:8123/api/webhook/dein_webhook_2' x = False # initialize x to False async def check_members(): global x # use the global x variable while True: voice_channel = client.get_channel(channel_id) num_members = len(voice_channel.members) if num_members >= 1: if not x: x = True requests.post(webhook_url1) #es ist mindestens eine Person im Sprachkanal else: if x: x = False requests.post(webhook_url2) #niemand ist im Sprachkanal await asyncio.sleep(30) # warte 30 Sekunden, bis du den Sprachkanal erneut überprüfst @client.event async def on_ready(): print(f"Logged in as {client.user}") client.loop.create_task(check_members()) asyncio.run(client.start(token))