wop's picture
Update app.py
07563b0 verified
raw
history blame
1.25 kB
import asyncio
import os
import threading
import random
from threading import Event
from typing import Optional
import requests
import discord
import gradio as gr
from gradio_client import Client
from discord import Permissions
from discord.ext import commands
from discord.utils import oauth_url
from gradio_client.utils import QueueError
event = Event()
async def wait(job):
while not job.done():
await asyncio.sleep(0.2)
# settings v ####################################################################
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
intents = discord.Intents.all()
bot = commands.Bot(command_prefix="$", intents=intents, help_command=None)
# bot stuff v ####################################################################
# end of stuff v ####################################################################
# running in thread
def run_bot():
if not DISCORD_TOKEN:
print("DISCORD_TOKEN NOT SET")
event.set()
else:
bot.run(DISCORD_TOKEN)
threading.Thread(target=run_bot).start()
event.wait()
with gr.Blocks() as demo:
gr.Markdown(
f"""
# Discord bot is online!
"""
)
demo.launch()