YusarinBot/yusarin.py

57 lines
2.1 KiB
Python
Raw Normal View History

2022-02-06 02:58:55 +02:00
try:
2023-01-17 16:05:39 +02:00
from requests import get
2023-01-17 16:50:47 +02:00
from discord import ApplicationContext, Intents, Bot, ActivityType, Activity, VoiceState
2022-02-06 02:58:55 +02:00
except Exception as exp:
2023-01-17 16:05:39 +02:00
print(f"Dependencies not installed. Make sure to run 'pip install -r requirements.txt' before first start")
exit()
2022-02-06 02:58:55 +02:00
2023-01-17 16:50:47 +02:00
from os import getpid
2023-01-17 16:05:39 +02:00
from shutil import rmtree
2022-02-05 02:31:32 +02:00
from functions import *
2023-01-17 16:05:39 +02:00
pid = getpid()
version = 1.8
2022-02-14 19:07:31 +02:00
if loadJson("config.json")["owner"] == "SET-OWNER-ID" or loadJson("config.json")["bot_token"] == "SET-BOT-TOKEN":
2023-01-17 16:21:26 +02:00
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")
2023-01-17 16:05:39 +02:00
exit()
2022-02-07 03:06:01 +02:00
if loadJson("config.json")["check_for_updates"]:
try:
2023-01-17 16:05:39 +02:00
serv_ver = loads(get("https://api.end-play.xyz/version?app=yusarinbot&apikey=publickey").text)["version"]
2022-02-07 03:06:01 +02:00
if float(serv_ver) > version:
2022-07-15 23:28:01 +03:00
appendLog(f"YusarinBot version {serv_ver} is available. Download new version here: https://git.end-play.xyz/profitroll/YusarinBot/releases/latest")
2022-02-07 03:06:01 +02:00
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)}")
2022-02-05 02:31:32 +02:00
2022-05-09 00:09:19 +03:00
intents = Intents().all()
2023-01-17 16:05:39 +02:00
client = Bot(intents=intents)
2022-02-05 02:31:32 +02:00
2023-01-17 16:50:47 +02:00
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))
2022-02-05 02:31:32 +02:00
@client.event
async def on_ready():
2022-02-07 03:06:01 +02:00
appendLog(f"Logged in as {client.user}")
2022-02-05 02:31:32 +02:00
config = loadJson("config.json")
2023-01-17 16:05:39 +02:00
await client.change_presence(activity=Activity(type=ActivityType.listening, name=config["bot_activity"]))
2022-02-05 02:31:32 +02:00
2022-02-07 03:06:01 +02:00
await clearTrash(client)
2022-02-05 02:31:32 +02:00
2023-01-17 16:50:47 +02:00
client.add_cog(CogCategory(client))
client.add_cog(CogChannel(client))
client.add_cog(CogLocale(client))
client.add_cog(CogUtility(client))
2022-02-05 02:31:32 +02:00
2022-05-09 00:09:19 +03:00
appendLog(f"Trying to log in...")
client.run(loadJson("config.json")["bot_token"])