Add presense endpoint and client function
This commit is contained in:
13
main.py
13
main.py
@@ -4,7 +4,7 @@ import os
|
||||
import platform
|
||||
import socketio
|
||||
import asyncio
|
||||
from discord import Intents, opus
|
||||
from discord import Intents, opus, Activity, ActivityType
|
||||
from discord.ext import commands
|
||||
from NoiseGatev2 import NoiseGate
|
||||
from debugger import setup_logger, running_dir
|
||||
@@ -46,6 +46,11 @@ def load_opus():
|
||||
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):
|
||||
global device_id, ng_threshold
|
||||
channel = client.get_channel(int(channel_id))
|
||||
@@ -144,6 +149,12 @@ async def connect_error():
|
||||
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
|
||||
async def join_server(data):
|
||||
logger.info(f"Received command to join server: {data['channelId']}")
|
||||
|
||||
Reference in New Issue
Block a user