YusarinBot/yusarin.py

57 lines
2.1 KiB
Python

try:
from requests import get
from discord import ApplicationContext, Intents, Bot, ActivityType, Activity, VoiceState
except Exception as exp:
print(f"Dependencies not installed. Make sure to run 'pip install -r requirements.txt' before first start")
exit()
from os import getpid
from shutil import rmtree
from functions import *
pid = getpid()
version = 1.8
if loadJson("config.json")["owner"] == "SET-OWNER-ID" or loadJson("config.json")["bot_token"] == "SET-BOT-TOKEN":
print(f"Bot is not correctly configured.\nMake sure you've set up owner id and bot token in 'config.json'\nLearn more here: https://git.end-play.xyz/profitroll/YusarinBot")
exit()
if loadJson("config.json")["check_for_updates"]:
try:
serv_ver = loads(get("https://api.end-play.xyz/version?app=yusarinbot&apikey=publickey").text)["version"]
if float(serv_ver) > version:
appendLog(f"YusarinBot version {serv_ver} is available. Download new version here: https://git.end-play.xyz/profitroll/YusarinBot/releases/latest")
appendLog(f"Currently using YusarinBot v{str(version)}")
except Exception as exp:
appendLog(f"Could not get YusarinBot cloud version due to {exp}. Currently using {str(version)}")
intents = Intents().all()
client = Bot(intents=intents)
from cogs.cogCategory import CogCategory
from cogs.cogChannel import CogChannel
from cogs.cogLocale import CogLocale
from cogs.cogUtility import CogUtility
@client.slash_command(name="help", description="Get information about this server")
async def help(ctx: ApplicationContext):
await ctx.respond(embed=getHelpMessage(ctx, version))
@client.event
async def on_ready():
appendLog(f"Logged in as {client.user}")
config = loadJson("config.json")
await client.change_presence(activity=Activity(type=ActivityType.listening, name=config["bot_activity"]))
await clearTrash(client)
client.add_cog(CogCategory(client))
client.add_cog(CogChannel(client))
client.add_cog(CogLocale(client))
client.add_cog(CogUtility(client))
appendLog(f"Trying to log in...")
client.run(loadJson("config.json")["bot_token"])