HuggingMod / app.py
lunarflu's picture
lunarflu HF staff
logbot
a994ac1
raw
history blame
No virus
1.72 kB
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()