Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,20 +12,8 @@ from gradio_client import Client
|
|
| 12 |
|
| 13 |
|
| 14 |
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
class Bot(commands.Bot):
|
| 18 |
-
"""This structure allows slash commands to work instantly."""
|
| 19 |
-
|
| 20 |
-
def __init__(self):
|
| 21 |
-
super().__init__(command_prefix="/", intents=discord.Intents.all())
|
| 22 |
-
|
| 23 |
-
async def setup_hook(self):
|
| 24 |
-
await self.tree.sync(guild=discord.Object(MY_GUILD_ID))
|
| 25 |
-
print(f"Synced slash commands for {self.user}.")
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
bot = Bot()
|
| 29 |
|
| 30 |
XP_PER_MESSAGE = 10
|
| 31 |
|
|
@@ -78,23 +66,19 @@ def calculate_level(xp):
|
|
| 78 |
|
| 79 |
@bot.command()
|
| 80 |
async def level(ctx):
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
if ctx.author.id
|
| 86 |
-
if ctx.author.id in xp_data:
|
| 87 |
-
|
| 88 |
-
xp = xp_data[ctx.author.id]
|
| 89 |
-
level = calculate_level(xp)
|
| 90 |
-
|
| 91 |
-
await ctx.send(f'You are at level {level} with {xp} total XP.')
|
| 92 |
-
# progress bar with ascii? could be nice, easy
|
| 93 |
-
else:
|
| 94 |
-
await ctx.send('You have not earned any XP yet.')
|
| 95 |
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
|
| 100 |
@bot.command()
|
|
@@ -148,17 +132,9 @@ async def load_xp(ctx):
|
|
| 148 |
|
| 149 |
""""""
|
| 150 |
def run_bot():
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
threading.Thread(target=run_bot).start()
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
This space hosts the huggingbots discord bot.
|
| 160 |
-
Currently supported models are Falcon and DeepfloydIF
|
| 161 |
-
""")
|
| 162 |
-
demo.queue(concurrency_count=100)
|
| 163 |
-
demo.queue(max_size=100)
|
| 164 |
-
demo.launch()
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
|
| 15 |
+
intents = discord.Intents.all()
|
| 16 |
+
bot = commands.Bot(command_prefix='!', intents=intents)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
XP_PER_MESSAGE = 10
|
| 19 |
|
|
|
|
| 66 |
|
| 67 |
@bot.command()
|
| 68 |
async def level(ctx):
|
| 69 |
+
global xp_data
|
| 70 |
+
print(ctx.author.id)
|
| 71 |
+
print(ctx.author.mention)
|
| 72 |
+
if ctx.author.id == 811235357663297546: # lunarflu
|
| 73 |
+
if ctx.author.id in xp_data:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
+
xp = xp_data[ctx.author.id]
|
| 76 |
+
level = calculate_level(xp)
|
| 77 |
+
|
| 78 |
+
await ctx.send(f'You are at level {level} with {xp} total XP.')
|
| 79 |
+
# progress bar with ascii? could be nice, easy
|
| 80 |
+
else:
|
| 81 |
+
await ctx.send('You have not earned any XP yet.')
|
| 82 |
|
| 83 |
|
| 84 |
@bot.command()
|
|
|
|
| 132 |
|
| 133 |
""""""
|
| 134 |
def run_bot():
|
| 135 |
+
bot.run(DISCORD_TOKEN)
|
|
|
|
|
|
|
| 136 |
threading.Thread(target=run_bot).start()
|
| 137 |
+
def greet(name):
|
| 138 |
+
return "Hello " + name + "!"
|
| 139 |
+
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 140 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|