lunarflu HF staff commited on
Commit
a994ac1
1 Parent(s): 7a2e8ce
Files changed (1) hide show
  1. app.py +74 -0
app.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import discord
2
+ import os
3
+ import threading
4
+ from discord.ext import commands
5
+ import json
6
+ import datetime
7
+
8
+ import gradio_client
9
+ import gradio as gr
10
+ from gradio_client import Client
11
+
12
+ DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
13
+ intents = discord.Intents.all()
14
+ bot = commands.Bot(command_prefix='!', intents=intents)
15
+
16
+
17
+ """LOG CHANNEL"""
18
+ LOG_CHANNEL_ID = 0
19
+
20
+ @bot.event
21
+ async def on_ready():
22
+ print(f'Logged in as {bot.user.name}')
23
+
24
+
25
+ # on_delete
26
+ @bot.event
27
+ async def on_message_delete(message):
28
+ try:
29
+
30
+ except Exception as e:
31
+ print(f"Error: {e}")
32
+
33
+
34
+ # on_edit
35
+ # on_ban
36
+
37
+ # on_join
38
+ # on_leave
39
+
40
+ @bot.event
41
+ async def on_message(message):
42
+ try:
43
+ if message.author != bot.user:
44
+ """AWAIT LEVEL ALGORITM OR SOMETHING (MULTIPLE FILES?)"""
45
+ author_id = str(message.author.id) # dictionary pairs (ID -> TOTAL XP)
46
+ xp_data.setdefault(author_id, 0) # default if it doesn't already exist
47
+
48
+ xp_data[author_id] += XP_PER_MESSAGE
49
+ print(f"xp_data: {xp_data}")
50
+ save_xp_data()
51
+
52
+ user = bot.get_user(811235357663297546)
53
+ try:
54
+ await user.send(f"xp_data: {xp_data}")
55
+ except discord.HTTPException:
56
+ await ctx.send("Failed to send a DM.")
57
+
58
+ await bot.process_commands(message)
59
+ except Exception as e:
60
+ print(f"Error: {e}")
61
+
62
+
63
+
64
+
65
+
66
+ """"""
67
+ DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
68
+ def run_bot():
69
+ bot.run(DISCORD_TOKEN)
70
+ threading.Thread(target=run_bot).start()
71
+ def greet(name):
72
+ return "Hello " + name + "!"
73
+ demo = gr.Interface(fn=greet, inputs="text", outputs="text")
74
+ demo.launch()