Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import discord
|
| 2 |
+
import os
|
| 3 |
+
import threading
|
| 4 |
+
from discord.ext import commands
|
| 5 |
+
|
| 6 |
+
import gradio_client
|
| 7 |
+
import gradio as gr
|
| 8 |
+
from gradio_client import Client
|
| 9 |
+
|
| 10 |
+
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
|
| 11 |
+
intents = discord.Intents.all()
|
| 12 |
+
bot = commands.Bot(command_prefix='!', intents=intents)
|
| 13 |
+
|
| 14 |
+
@bot.event
|
| 15 |
+
async def on_message(message):
|
| 16 |
+
try:
|
| 17 |
+
if message.author != bot.user:
|
| 18 |
+
|
| 19 |
+
except Exception as e:
|
| 20 |
+
print(f"Error: {e}")
|
| 21 |
+
|
| 22 |
+
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
|
| 23 |
+
def run_bot():
|
| 24 |
+
bot.run(DISCORD_TOKEN)
|
| 25 |
+
threading.Thread(target=run_bot).start()
|
| 26 |
+
def greet(name):
|
| 27 |
+
return "Hello " + name + "!"
|
| 28 |
+
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 29 |
+
demo.launch()
|