File size: 1,252 Bytes
8a0bc2e e50b540 8a0bc2e 58c201b 502d7e9 f82ba90 8a0bc2e 940edd3 54389af 58c201b 8a0bc2e 54389af 58c201b 54389af 8a0bc2e 58c201b 54389af 58c201b 54389af 8a0bc2e 54389af 8a0bc2e 54389af 940edd3 54389af 8a0bc2e 54389af 8a0bc2e ea3dcdc 08fb6c7 58c201b |
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 |
import os
import random
import threading
import discord
import gradio as gr
from discord import app_commands
from discord.ext import commands
# HF GUILD SETTINGS
MY_GUILD_ID = 1077674588122648679 if os.getenv("TEST_ENV", False) else 879548962464493619
MY_GUILD = discord.Object(id=MY_GUILD_ID)
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
class Bot(commands.Bot):
"""This structure allows slash commands to work instantly."""
def __init__(self):
super().__init__(command_prefix="/", intents=discord.Intents.all())
async def setup_hook(self):
await self.tree.sync(guild=discord.Object(MY_GUILD_ID))
print(f"Synced slash commands for {self.user}.")
client = Bot()
@client.event
async def on_ready():
print(f"Logged in as {client.user} (ID: {client.user.id})")
print("------")
def run_bot():
client.run(DISCORD_TOKEN)
threading.Thread(target=run_bot).start()
"""This allows us to run the Discord bot in a Python thread"""
with gr.Blocks() as demo:
gr.Markdown("""
# Huggingbots Server
This space hosts the huggingbots discord bot.
Currently supported models are Falcon and DeepfloydIF
""")
demo.queue(concurrency_count=100)
demo.queue(max_size=100)
demo.launch()
|