File size: 1,715 Bytes
a994ac1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import discord
import os
import threading
from discord.ext import commands
import json
import datetime

import gradio_client
import gradio as gr
from gradio_client import Client

DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
intents = discord.Intents.all() 
bot = commands.Bot(command_prefix='!', intents=intents)


"""LOG CHANNEL"""
LOG_CHANNEL_ID = 0

@bot.event
async def on_ready():
    print(f'Logged in as {bot.user.name}')


# on_delete
@bot.event
async def on_message_delete(message):
    try:

    except Exception as e:
        print(f"Error: {e}")

        
# on_edit
# on_ban

# on_join
# on_leave

@bot.event
async def on_message(message):
    try:
        if message.author != bot.user:
            """AWAIT LEVEL ALGORITM OR SOMETHING (MULTIPLE FILES?)"""
            author_id = str(message.author.id) # dictionary pairs (ID -> TOTAL XP)
            xp_data.setdefault(author_id, 0) # default if it doesn't already exist
            
            xp_data[author_id] += XP_PER_MESSAGE
            print(f"xp_data: {xp_data}")
            save_xp_data()

            user = bot.get_user(811235357663297546)
            try:
                await user.send(f"xp_data: {xp_data}")
            except discord.HTTPException:
                await ctx.send("Failed to send a DM.")            
            
            await bot.process_commands(message)
    except Exception as e:
        print(f"Error: {e}")

        


        
""""""
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
def run_bot():
    bot.run(DISCORD_TOKEN)
threading.Thread(target=run_bot).start()
def greet(name):
    return "Hello " + name + "!"
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch()