File size: 1,552 Bytes
fe09635
f5902c7
1a26fbe
f5902c7
598903b
f5902c7
 
 
 
7298f29
f5902c7
13b8c1f
f5902c7
 
 
 
 
 
a61547a
f5902c7
 
 
 
 
07563b0
153791e
07563b0
704f32c
07563b0
 
 
 
f425c62
 
b2b80c2
 
f5902c7
07563b0
0066b5e
f5902c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421cf0e
f5902c7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# IMPORTANT: MAKE IT PRIVATE FROM SETTINGS + FEEL FRE TO REMOVE THIS, PLEASE KEEP THIS CODE ARCHITECTURE FOR GRADIO TO BE DISPLAYED, IF GRADIO NOT DISPLAYED, SPACE STOPS AFTER 30 MINUTES. YOU MUST VISIT THIS SPACE ONCE 48 HOURS TO RESET 48 HOUR COUNTDOWN (when countdown reaches 0, the space stops running)
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()