update bot

This commit is contained in:
2025-03-08 18:18:23 -07:00
parent ba9bd66efd
commit 7a307f6a6d
4 changed files with 19 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
FROM node:20 as build-stage FROM node:20 AS build-stage
WORKDIR /app WORKDIR /app
@@ -8,7 +8,7 @@ RUN npm install
COPY client/ ./ COPY client/ ./
RUN npm run build RUN npm run build
FROM python:3.10 FROM python:3.12
RUN apt-get update && apt-get install -y ffmpeg RUN apt-get update && apt-get install -y ffmpeg
COPY requirements.txt requirements.txt COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt RUN pip install -r requirements.txt

View File

@@ -93,20 +93,24 @@ async def stop(ctx: commands.Context):
async def pause(ctx: commands.Context): async def pause(ctx: commands.Context):
pause_song() pause_song()
def run_websocket(): # def run_websocket():
print("started websocket") # print("started websocket")
loop = asyncio.new_event_loop() # loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop) # asyncio.set_event_loop(loop)
start_server = websockets.serve(websocket_handler, "0.0.0.0", 5678) # start_server = websockets.serve(websocket_handler, "0.0.0.0", 5678)
loop.run_until_complete(start_server) # loop.run_until_complete(start_server)
loop.run_forever() # loop.run_forever()
async def start_websocket_server():
print("Starting WebSocket server...")
async with websockets.serve(websocket_handler, "0.0.0.0", 5678):
await asyncio.Future()
@asynccontextmanager @asynccontextmanager
async def lifespan(app: FastAPI): async def lifespan(app: FastAPI):
Thread(target=run_websocket).start() asyncio.create_task(start_websocket_server())
Thread(target=lambda: bot.run(os.getenv("DISCORD_SECRET"))).start() asyncio.create_task(bot.start(os.getenv("DISCORD_SECRET")))
yield yield
app = FastAPI(lifespan=lifespan) app = FastAPI(lifespan=lifespan)

View File

@@ -7,3 +7,4 @@ ffmpeg
pydantic pydantic
mutagen mutagen
fastapi fastapi
fastapi[standard]

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
docker pull node:20 docker pull node:20
docker pull python:3.10 docker pull python:3.12
docker build -t discord-bot . docker build -t discord-bot .
# docker run -it --rm discord-bot # docker run -it --rm discord-bot