Add presense endpoint and client function

This commit is contained in:
Logan Cusano
2024-05-05 18:28:00 -04:00
parent 098dfc9a10
commit 549a87bed0

13
main.py
View File

@@ -4,7 +4,7 @@ import os
import platform import platform
import socketio import socketio
import asyncio import asyncio
from discord import Intents, opus from discord import Intents, opus, Activity, ActivityType
from discord.ext import commands from discord.ext import commands
from NoiseGatev2 import NoiseGate from NoiseGatev2 import NoiseGate
from debugger import setup_logger, running_dir from debugger import setup_logger, running_dir
@@ -46,6 +46,11 @@ def load_opus():
return False return False
async def set_discord_presense(presense):
# Set the presence of the bot (what it's listening to)
await client.change_presence(activity=Activity(type=ActivityType.listening, name=presense))
async def join_voice_channel(channel_id): async def join_voice_channel(channel_id):
global device_id, ng_threshold global device_id, ng_threshold
channel = client.get_channel(int(channel_id)) channel = client.get_channel(int(channel_id))
@@ -144,6 +149,12 @@ async def connect_error():
logger.error("Connection to WebSocket server failed") logger.error("Connection to WebSocket server failed")
@sio.event
async def set_system(data):
logger.info(f"Received command to set system name (presense): {data['system']}")
return await set_discord_presense(data['system'])
@sio.event @sio.event
async def join_server(data): async def join_server(data):
logger.info(f"Received command to join server: {data['channelId']}") logger.info(f"Received command to join server: {data['channelId']}")