Update 1.5

This commit is contained in:
Profitroll 2022-05-08 23:09:19 +02:00
parent 4254570efc
commit c06031e893
5 changed files with 155 additions and 323 deletions

View File

@ -1,8 +1,9 @@
import gzip
import os import os
import sys import sys
import json import json
import shutil import shutil
import discord import discord # type: ignore
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
@ -64,7 +65,7 @@ def appendLog(message, guild=None, announce=True):
checkSize() checkSize()
log = open(path + '/logs/latest.log', 'a') log = open(path + '/logs/latest.log', 'a') # type: ignore
log.write(f'{message_formatted}\n') log.write(f'{message_formatted}\n')
log.close() log.close()
@ -310,46 +311,44 @@ async def clearTrash(client):
#async def autoClearTrash(client): #async def autoClearTrash(client):
# execute clearTrash every 120 seconds # execute clearTrash every 120 seconds
def getHelpMessage(message, version, prefix=loadJson("config.json")["bot_prefix"]): def getHelpMessage(ctx, version):
#channelExists(number, guild, type="Voice") #channelExists(number, guild, type="Voice")
config = loadJson("config.json") config = loadJson("config.json")
if message.guild is not None: if ctx.guild is not None:
if channelExists(guildConfGet(message.guild, 'channel'), message.guild, type="Voice"): if channelExists(guildConfGet(ctx.guild, 'channel'), ctx.guild, type="Voice"):
desc_channel = getMsg("help_channel_set", guild=message.guild).format(channelGetName(guildConfGet(message.guild, 'channel'), message.guild)) desc_channel = getMsg("help_channel_set", guild=ctx.guild).format(channelGetName(guildConfGet(ctx.guild, 'channel'), ctx.guild))
else: else:
desc_channel = getMsg("help_channel_none", guild=message.guild) desc_channel = getMsg("help_channel_none", guild=ctx.guild)
if channelExists(guildConfGet(message.guild, 'category'), message.guild, type="Any"): if channelExists(guildConfGet(ctx.guild, 'category'), ctx.guild, type="Any"):
desc_category = getMsg("help_category_set", guild=message.guild).format(channelGetName(guildConfGet(message.guild, 'category'), message.guild)) desc_category = getMsg("help_category_set", guild=ctx.guild).format(channelGetName(guildConfGet(ctx.guild, 'category'), ctx.guild))
else: else:
desc_category = getMsg("help_category_none", guild=message.guild) desc_category = getMsg("help_category_none", guild=ctx.guild)
desc_prefix = getMsg("help_prefix", guild=message.guild).format(prefix) desc_locale = getMsg("help_locale", guild=ctx.guild).format(getMsg("locale_name", ctx.guild))
desc_locale = getMsg("help_locale", guild=message.guild).format(getMsg("locale_name", message.guild))
description = "\n".join([desc_prefix, desc_locale, desc_channel, desc_category]) description = "\n".join([desc_locale, desc_channel, desc_category])
embed=discord.Embed(title=getMsg("help_title", message.guild), description=description, color=strToColor(config["color_default"])) embed=discord.Embed(title=getMsg("help_title", ctx.guild), description=description, color=strToColor(config["color_default"]))
else: else:
embed=discord.Embed(title=getMsg("help_title_dm", message.guild), color=strToColor(config["color_default"])) embed=discord.Embed(title=getMsg("help_title_dm", ctx.guild), color=strToColor(config["color_default"]))
embed.set_author(name=f'{config["bot_name"]} v{str(version)}', url=config["bot_site"], icon_url=config["bot_icon"]) embed.set_author(name=f'{config["bot_name"]} v{str(version)}', url=config["bot_site"], icon_url=config["bot_icon"])
if message.author.id == config["owner"]: if ctx.author.id == config["owner"]:
embed.add_field(name=f"{prefix}shutdown", value=getMsg("help_cmd_shutdown", message.guild), inline=False) embed.add_field(name=f"/shutdown", value=getMsg("help_cmd_shutdown", ctx.guild), inline=False)
embed.add_field(name=f"{prefix}channel ID", value=getMsg("help_cmd_channel", message.guild), inline=False) embed.add_field(name=f"/channel set", value=getMsg("help_cmd_channel", ctx.guild), inline=False)
embed.add_field(name=f"{prefix}category ID", value=getMsg("help_cmd_category", message.guild), inline=False) embed.add_field(name=f"/category set", value=getMsg("help_cmd_category", ctx.guild), inline=False)
embed.add_field(name=f"{prefix}prefix SYMBOL", value=getMsg("help_cmd_prefix", message.guild), inline=False) embed.add_field(name=f"/locale set", value=getMsg("help_cmd_locale", ctx.guild), inline=False)
embed.add_field(name=f"{prefix}locale LOCALE", value=getMsg("help_cmd_locale", message.guild), inline=False)
if message.guild is None: if ctx.guild is None:
embed.set_footer(text=getMsg("help_server", message.guild)) embed.set_footer(text=getMsg("help_server", ctx.guild))
else: else:
embed.set_footer(text=getMsg("help_notice_id", message.guild)) embed.set_footer(text=getMsg("help_notice_id", ctx.guild))
return embed return embed
@ -358,26 +357,14 @@ async def guildConfigured(guild):
output = {} output = {}
config = loadJson("config.json") config = loadJson("config.json")
for kind in ["channel", "category", "prefix"]: for kind in ["channel", "category"]:
if guildConfGet(guild, kind) is not None: if guildConfGet(guild, kind) is not None:
try: try:
if kind == "channel": guild_object = discord.utils.get(guild.categories, id=guildConfGet(guild, kind))
guild_object = discord.utils.get(guild.channels, id=guildConfGet(guild, kind)) output[kind] = getMsg("configured_"+kind, guild).format(guild_object.name)
output[kind] = getMsg("configured_"+kind, guild).format(guild_object.name)
elif kind == "category":
guild_object = discord.utils.get(guild.categories, id=guildConfGet(guild, kind))
output[kind] = getMsg("configured_"+kind, guild).format(guild_object.name)
elif kind == "prefix":
output[kind] = getMsg("info_prefix", guild).format(guildConfGet(guild, kind))
except Exception as exp: except Exception as exp:
if kind == "prefix":
output[kind] = getMsg("info_prefix", guild).format(config["bot_prefix"])
else:
output[kind] = getMsg("unconfigured_"+kind, guild)
else:
if kind == "prefix":
output[kind] = getMsg("info_prefix", guild).format(config["bot_prefix"])
else:
output[kind] = getMsg("unconfigured_"+kind, guild) output[kind] = getMsg("unconfigured_"+kind, guild)
else:
output[kind] = getMsg("unconfigured_"+kind, guild)
return getMsg("server_config", guild).format(output["prefix"], getMsg("info_locale", guild).format(getMsg("locale_name", guild)), output["channel"], output["category"]) return getMsg("server_config", guild).format(getMsg("info_locale", guild).format(getMsg("locale_name", guild)), output["channel"], output["category"])

View File

@ -9,40 +9,31 @@
"set_channel_description": "Voice channel `{0}` has been set as a parent.", "set_channel_description": "Voice channel `{0}` has been set as a parent.",
"set_category_title": "☑ Parent category set", "set_category_title": "☑ Parent category set",
"set_category_description": "Category `{0}` has been set as the parent category.", "set_category_description": "Category `{0}` has been set as the parent category.",
"set_prefix_title": "☑ Command prefix set",
"set_prefix_description": "On this server, all commands are now prefixed with `{0}`",
"set_locale_title": "☑ Bot language set", "set_locale_title": "☑ Bot language set",
"set_locale_description": "This server is now using `{0}`", "set_locale_description": "This server is now using `{0}`",
"reset_channel_title": "☑ Parent channel reset", "reset_channel_title": "☑ Parent channel reset",
"reset_channel_description": "Use `{0}channel CHANNELID` to select a new channel", "reset_channel_description": "Use `/channel set` to select a new channel",
"reset_category_title": "☑ Parent category reset", "reset_category_title": "☑ Parent category reset",
"reset_category_description": "Use `{0}category ID-CATEGORY` to select a new category", "reset_category_description": "Use `/category set` to select a new category",
"reset_prefix_title": "☑ Command Prefix Reset",
"reset_prefix_description": "The default prefix `{0}` is now used.\nUse `{1}prefix CHAR` to select a new one",
"reset_locale_title": "☑ Bot language reset", "reset_locale_title": "☑ Bot language reset",
"reset_locale_description": "The default locale `{0}` is now used.\nUse `{1}locale LANGUAGE` to select a different one", "reset_locale_description": "The default locale `{0}` is now used.\nUse `/locale set` to select a different one",
"error_channel_title": "🚫 Error installing channel", "error_channel_title": "🚫 Error installing channel",
"error_channel_description": "Correct Usage: `{0}channel CHANNELID`", "error_channel_description": "Correct Usage: `/channel set`",
"error_category_title": "🚫 Error setting category", "error_category_title": "🚫 Error setting category",
"error_category_description": "Correct Usage: `{0}category CATEGORY-ID`", "error_category_description": "Correct Usage: `/category set`",
"error_prefix_title": "🚫 Error setting prefix",
"error_prefix_description": "Correct Usage: `{0}prefix SYMBOL`",
"error_locale_title": "🚫 Error installing language", "error_locale_title": "🚫 Error installing language",
"error_locale_description": "Correct Usage: `{0}locale LANGUAGE`\nAvailable languages: {1}", "error_locale_description": "Correct Usage: `/locale set`\nAvailable languages: {1}",
"hint_none_channel_title": "⚠ No parent channel set", "hint_none_channel_title": "⚠ No parent channel set",
"hint_none_channel_description": "For the bot to work properly, you need to set the parent channel, by entering which the user can create his own private voice channel. Set the parent channel with the command `{0}channel CHANNEL-ID`", "hint_none_channel_description": "For the bot to work properly, you need to set the parent channel, by entering which the user can create his own private voice channel. Set the parent channel with the command `/channel set`",
"hint_none_category_title": "⚠ No parent category set", "hint_none_category_title": "⚠ No parent category set",
"hint_none_category_description": "For the bot to work properly, you need to set a parent category, within which a private channel will be created for the user. Set the parent category with the command `{0}category ID-CATEGORY`", "hint_none_category_description": "For the bot to work properly, you need to set a parent category, within which a private channel will be created for the user. Set the parent category with the command `/category set`",
"hint_none_prefix_title": "⚠ No prefix set",
"hint_none_prefix_description": "This server uses the default `{0}`.\nTo change it use `{1}prefix CHAR`",
"hint_none_locale_title": "⚠ Bot language not set", "hint_none_locale_title": "⚠ Bot language not set",
"hint_none_locale_description": "This server uses default `{0}`.\nTo change it use `{1}locale LANGUAGE`", "hint_none_locale_description": "This server uses default `{0}`.\nTo change it use `/locale set`",
"error_text_channel_title": "🚫 Error installing channel", "error_text_channel_title": "🚫 Error installing channel",
"error_text_channel_description": "The selected channel must be a voice channel.", "error_text_channel_description": "The selected channel must be a voice channel.",
"help_title": "Server Information", "help_title": "Server Information",
"help_title_dm": "Bot Commands", "help_title_dm": "Bot Commands",
"help_server": "Commands must be run on the server", "help_server": "Commands must be run on the server",
"help_prefix": " Command prefix: `{0}`",
"help_locale": " Server bot language: `{0}`", "help_locale": " Server bot language: `{0}`",
"help_channel_set": "☑ Parent channel: `{0}`", "help_channel_set": "☑ Parent channel: `{0}`",
"help_channel_none": "⚠ Parent channel not installed", "help_channel_none": "⚠ Parent channel not installed",
@ -51,7 +42,6 @@
"help_cmd_shutdown": "Shut the bot down", "help_cmd_shutdown": "Shut the bot down",
"help_cmd_channel": "Set parent channel\nMust be a voice channel", "help_cmd_channel": "Set parent channel\nMust be a voice channel",
"help_cmd_category": "Set parent category", "help_cmd_category": "Set parent category",
"help_cmd_prefix": "Set command prefix",
"help_cmd_locale": "Change bot language on server", "help_cmd_locale": "Change bot language on server",
"help_notice_id": "Note that channel name ≠ channel ID", "help_notice_id": "Note that channel name ≠ channel ID",
"help_notice_id_category": "Note that category name ≠ category ID", "help_notice_id_category": "Note that category name ≠ category ID",

View File

@ -9,40 +9,31 @@
"set_channel_description": "Голосовий канал `{0}` був встановлений як твірний.", "set_channel_description": "Голосовий канал `{0}` був встановлений як твірний.",
"set_category_title": "☑ Твірну категорію встановлено", "set_category_title": "☑ Твірну категорію встановлено",
"set_category_description": "Категорія `{0}` була встановлена ​​як твірна.", "set_category_description": "Категорія `{0}` була встановлена ​​як твірна.",
"set_prefix_title": "☑ Префікс команд встановлено",
"set_prefix_description": "На цьому сервері префікс усіх команд тепер `{0}`",
"set_locale_title": "☑ Мова бота встановлена", "set_locale_title": "☑ Мова бота встановлена",
"set_locale_description": "На цьому сервері тепер використовується `{0}`", "set_locale_description": "На цьому сервері тепер використовується `{0}`",
"reset_channel_title": "☑ Твірний канал скинутий", "reset_channel_title": "☑ Твірний канал скинутий",
"reset_channel_description": "Для вибору нового каналу використовуйте `{0}channel ID-КАНАЛу`", "reset_channel_description": "Для вибору нового каналу використовуйте `/channel set`",
"reset_category_title": "☑ Твірна категорія скинута", "reset_category_title": "☑ Твірна категорія скинута",
"reset_category_description": "Для вибору нової категорії використовуйте `{0}category ID-КАТЕГОРІЇ`", "reset_category_description": "Для вибору нової категорії використовуйте `/category set`",
"reset_prefix_title": "☑ Префікс команд скинутий",
"reset_prefix_description": "Тепер використовується стандартний префікс `{0}`.\nДля вибору нового використовуйте `{1}prefix СИМВОЛ`",
"reset_locale_title": "☑ Мова бота скинута", "reset_locale_title": "☑ Мова бота скинута",
"reset_locale_description": "Тепер використовується стандартна мова `{0}`.\nДля вибору іншого використовуйте `{1}locale МОВА`", "reset_locale_description": "Тепер використовується стандартна мова `{0}`.\nДля вибору іншого використовуйте `/locale set`",
"error_channel_title": "🚫 Помилка установки каналу", "error_channel_title": "🚫 Помилка установки каналу",
"error_channel_description": "Правильне використання: `{0}channel ID-КАНАЛу`", "error_channel_description": "Правильне використання: `/channel set`",
"error_category_title": "🚫 Помилка установки категорії", "error_category_title": "🚫 Помилка установки категорії",
"error_category_description": "Правильне використання: `{0}category ID-КАТЕГОРІЇ`", "error_category_description": "Правильне використання: `/category set`",
"error_prefix_title": "🚫 Помилка встановлення префіксу",
"error_prefix_description": "Правильне використання: `{0}prefix СИМВОЛ`",
"error_locale_title": "🚫 Помилка встановлення мови", "error_locale_title": "🚫 Помилка встановлення мови",
"error_locale_description": "Правильне використання: `{0}locale МОВА`\nДоступні мови: {1}", "error_locale_description": "Правильне використання: `/locale set`\nДоступні мови: {1}",
"hint_none_channel_title": "⚠ Твірний канал не заданий", "hint_none_channel_title": "⚠ Твірний канал не заданий",
"hint_none_channel_description": "Для правильної роботи робота необхідно задати твірний канал, входячи в який користувач зможе створити свій приватний голосовий канал. Встановіть твірний канал командою `{0}channel ID-КАНАЛУ", "hint_none_channel_description": "Для правильної роботи робота необхідно задати твірний канал, входячи в який користувач зможе створити свій приватний голосовий канал. Встановіть твірний канал командою `/channel set`",
"hint_none_category_title": "⚠ Твірна категорія не задана", "hint_none_category_title": "⚠ Твірна категорія не задана",
"hint_none_category_description": "Для правильної роботи робота необхідно задати твірну категорію, всередині якої для користувача буде створено його приватний канал. Встановіть твірну категорію командою `{0}category ID-КАТЕГОРІЇ`", "hint_none_category_description": "Для правильної роботи робота необхідно задати твірну категорію, всередині якої для користувача буде створено його приватний канал. Встановіть твірну категорію командою `/category set`",
"hint_none_prefix_title": "⚠ Префікс не заданий",
"hint_none_prefix_description": "На цьому сервері використовується стандартний `{0}`.\nЩоб змінити його використовуйте `{1}prefix СИМВОЛ`",
"hint_none_locale_title": "⚠ Мова бота не задана", "hint_none_locale_title": "⚠ Мова бота не задана",
"hint_none_locale_description": "На цьому сервері використовується стандартний `{0}`.\nЩоб змінити його використовуйте `{1}locale МОВА`", "hint_none_locale_description": "На цьому сервері використовується стандартний `{0}`.\nЩоб змінити його використовуйте `/locale set`",
"error_text_channel_title": "🚫 Помилка установки каналу", "error_text_channel_title": "🚫 Помилка установки каналу",
"error_text_channel_description": "Вибраний канал повинен бути голосовим.", "error_text_channel_description": "Вибраний канал повинен бути голосовим.",
"help_title": "Інформація про сервер", "help_title": "Інформація про сервер",
"help_title_dm": "Команда бота", "help_title_dm": "Команда бота",
"help_server": "Команди повинні виконуватись на сервері", "help_server": "Команди повинні виконуватись на сервері",
"help_prefix": " Префікс команд: `{0}`",
"help_locale": " Мова бота на сервері: `{0}`", "help_locale": " Мова бота на сервері: `{0}`",
"help_channel_set": "☑ Твірний канал: `{0}`", "help_channel_set": "☑ Твірний канал: `{0}`",
"help_channel_none": "⚠ Твірний канал не встановлено", "help_channel_none": "⚠ Твірний канал не встановлено",
@ -51,7 +42,6 @@
"help_cmd_shutdown": "Вимкнути бота", "help_cmd_shutdown": "Вимкнути бота",
"help_cmd_channel": "Встановити твірний канал\nКанал повинен бути голосовим", "help_cmd_channel": "Встановити твірний канал\nКанал повинен бути голосовим",
"help_cmd_category": "Встановити твірну категорію", "help_cmd_category": "Встановити твірну категорію",
"help_cmd_prefix": "Встановити префікс команд",
"help_cmd_locale": "Змінити мову бота на сервері", "help_cmd_locale": "Змінити мову бота на сервері",
"help_notice_id": "Зверніть увагу, що ім'я каналу ≠ ID каналу", "help_notice_id": "Зверніть увагу, що ім'я каналу ≠ ID каналу",
"help_notice_id_category": "Зверніть увагу, що ім'я категорії ≠ ID категорії", "help_notice_id_category": "Зверніть увагу, що ім'я категорії ≠ ID категорії",

View File

@ -1 +1 @@
discord.py py-cord>=2.0

View File

@ -6,14 +6,15 @@ import requests
import threading import threading
try: try:
import discord import discord # type: ignore
from discord import ApplicationContext, Option, Intents # type: ignore
except Exception as exp: except Exception as exp:
print(f"Module discord.py is not installed. Make sure to run 'pip install -r requirements.txt' before first start") print(f"Module py-cord is not installed. Make sure to run 'pip install -r requirements.txt' before first start")
sys.exit() sys.exit()
from functions import * from functions import *
pid = os.getpid() pid = os.getpid()
version = 1.4 version = 1.5
if loadJson("config.json")["owner"] == "SET-OWNER-ID" or loadJson("config.json")["bot_token"] == "SET-BOT-TOKEN": 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 {path}/config.json\nLearn more here: https://github.com/profitrollgame/YusarinBot") print(f"Bot is not correctly configured.\nMake sure you've set up owner id and bot token in {path}/config.json\nLearn more here: https://github.com/profitrollgame/YusarinBot")
@ -21,15 +22,15 @@ if loadJson("config.json")["owner"] == "SET-OWNER-ID" or loadJson("config.json")
if loadJson("config.json")["check_for_updates"]: if loadJson("config.json")["check_for_updates"]:
try: try:
serv_ver = requests.get("https://www.end-play.xyz/yusarin/version.txt").text.replace('\n', '') serv_ver = json.loads(requests.get("https://api.end-play.xyz/version&apikey=publickey&app=yusarinbot").text)["version"]
if float(serv_ver) > version: if float(serv_ver) > version:
appendLog(f"YusarinBot version {serv_ver} is available. Download new version here: https://github.com/profitrollgame/YusarinBot/releases/latest") appendLog(f"YusarinBot version {serv_ver} is available. Download new version here: https://github.com/profitrollgame/YusarinBot/releases/latest")
appendLog(f"Currently using YusarinBot v{str(version)}") appendLog(f"Currently using YusarinBot v{str(version)}")
except Exception as exp: except Exception as exp:
appendLog(f"Could not get YusarinBot cloud version due to {exp}. Currently using {str(version)}") appendLog(f"Could not get YusarinBot cloud version due to {exp}. Currently using {str(version)}")
intents = discord.Intents().all() intents = Intents().all()
client = discord.Client(intents=intents) client = discord.Bot(intents=intents)
@client.event @client.event
async def on_ready(): async def on_ready():
@ -106,251 +107,115 @@ async def on_voice_state_update(member, before, after):
else: else:
appendLog(f"Category for guild {vc_to.guild} is not set", guild=vc_to.guild) appendLog(f"Category for guild {vc_to.guild} is not set", guild=vc_to.guild)
# ========================================================================================== #=========================================================================================================================
@client.slash_command(name="shutdown", description="Restart the bot")
@client.event async def shutdown(ctx: ApplicationContext):
async def on_message(message):
config = loadJson("config.json") config = loadJson("config.json")
if ctx.author.id == config["owner"]:
if message.guild is not None: await ctx.respond(embed=makeEmbed(description=getMsg("shutdown", ctx.guild).format(ctx.author), color=strToColor(config["color_default"])))
try: os.system(f"kill -9 {str(pid)}")
prefix = guildConfGet(message.guild, "prefix")
if prefix is None:
prefix = config["bot_prefix"]
except Exception as exp:
print(exp)
prefix = config["bot_prefix"]
else: else:
prefix = config["bot_prefix"] await ctx.respond(embed=makeEmbed(title=getMsg("admin_title", ctx.guild), description=getMsg("admin_description", ctx.guild), color=strToColor(config["color_error"])))
#=========================================================================================================================
if message.author == client.user: #=========================================================================================================================
@client.slash_command(name="help", description="Get information about this server")
return async def help(ctx: ApplicationContext):
await ctx.respond(embed=getHelpMessage(ctx, version))
#=========================================================================================================================
if message.content in [f"{prefix}reboot", f"{prefix}restart", f"{prefix}shutdown", f"{prefix}die"]: #=========================================================================================================================
locale = client.create_group("locale", "Commands related to bot's locale")
gotCommand(message)
valid_locales = []
if message.author.id == config["owner"]: files_locales = os.listdir(f"{path}/locale/")
for entry in files_locales:
await message.reply(embed=makeEmbed(description=getMsg("shutdown", message.guild).format(message.author), color=strToColor(config["color_default"])), mention_author=False) valid_locales.append(".".join(entry.split(".")[:-1]))
os.system(f"kill -9 {str(pid)}")
@locale.command(name="set", description="Set bot's messages language")
async def locale_set(ctx: ApplicationContext, language: Option(str, "One of the languages in list", choices=valid_locales)): # type: ignore
config = loadJson("config.json")
if ctx.guild is not None:
if language+".json" in os.listdir(f"{path}/locale/"):
guildConfSet(ctx.guild, "locale", language)
appendLog(f"Server's locale is now set to {language}", ctx.guild)
await ctx.respond(embed=makeEmbed(title=getMsg("set_locale_title", ctx.guild), description=getMsg("set_locale_description", ctx.guild).format(getMsg("locale_name", ctx.guild)), color=strToColor(config["color_ok"])))
else: else:
valid_locales = []
return files_locales = os.listdir(f"{path}/locale/")
for entry in files_locales:
elif message.content.startswith(f"{prefix}channel"): valid_locales.append(entry.split(".")[:-1])
await ctx.respond(embed=makeEmbed(title=getMsg("error_locale_title", ctx.guild), description=getMsg("error_locale_description", ctx.guild).format(", ".join(valid_locales)), color=strToColor(config["color_error"])))
gotCommand(message) else:
await ctx.respond(embed=makeEmbed(title=getMsg("dm_title", ctx.guild), description=getMsg("dm_description", ctx.guild), color=strToColor(config["color_error"])))
fullcmd = message.content.split()
if message.guild is not None:
if message.author.guild_permissions.administrator:
try:
if fullcmd[1] == "reset":
if guildConfGet(message.guild, "channel") is not None:
guildConfReset(message.guild, "channel")
await message.reply(embed=makeEmbed(title=getMsg("reset_channel_title", message.guild), description=getMsg("reset_channel_description", message.guild).format(prefix), color=strToColor(config["color_ok"])), mention_author=False)
else:
await message.reply(embed=makeEmbed(title=getMsg("hint_none_channel_title", message.guild), description=getMsg("hint_none_channel_description", message.guild).format(prefix), color=strToColor(config["color_warn"])), mention_author=False)
else:
selected_channel = discord.utils.get(message.guild.channels, id=int(fullcmd[1]))
if isinstance(selected_channel, discord.VoiceChannel):
guildConfSet(message.guild, "channel", int(fullcmd[1]))
await message.reply(embed=makeEmbed(title=getMsg("set_channel_title", message.guild), description=getMsg("set_channel_description", message.guild).format(selected_channel.name), color=strToColor(config["color_ok"])), mention_author=False)
if guildConfGet(message.guild, "category") is None:
await message.channel.send(embed=makeEmbed(title=getMsg("hint_none_category_title", message.guild), description=getMsg("hint_none_category_description", message.guild).format(prefix), color=strToColor(config["color_warn"])))
else:
await message.reply(embed=makeEmbed(title=getMsg("error_text_channel_title", message.guild), description=getMsg("error_text_channel_description", message.guild), color=strToColor(config["color_error"])), mention_author=False)
except Exception as exp:
if debug:
print(exp)
await message.reply(embed=makeEmbed(title=getMsg("error_channel_title", message.guild), description=getMsg("error_channel_description", message.guild).format(prefix), footer=getMsg("help_notice_id", message.guild), color=strToColor(config["color_error"])), mention_author=False)
else:
await message.reply(embed=makeEmbed(title=getMsg("forbidden_title", message.guild), description=getMsg("forbidden_description", message.guild), color=strToColor(config["color_error"])), mention_author=False)
@locale.command(name="reset", description="Reset the bot's language in this guild")
async def locale_reset(ctx: ApplicationContext): # type: ignore
config = loadJson("config.json")
if ctx.guild is not None:
if guildConfGet(ctx.guild, "locale") is not None:
guildConfReset(ctx.guild, "locale")
appendLog(f"Server's locale has been reset", ctx.guild)
await ctx.respond(embed=makeEmbed(title=getMsg("reset_locale_title", ctx.guild), description=getMsg("reset_locale_description", ctx.guild).format(getMsg("locale_name", ctx.guild)), color=strToColor(config["color_ok"])))
else: else:
await message.reply(embed=makeEmbed(title=getMsg("dm_title", message.guild), description=getMsg("dm_description", message.guild), color=strToColor(config["color_error"])), mention_author=False) await ctx.respond(embed=makeEmbed(title=getMsg("hint_none_locale_title", ctx.guild), description=getMsg("hint_none_locale_description", ctx.guild).format(getMsg("locale_name", ctx.guild)), color=strToColor(config["color_warn"])))
else:
elif message.content.startswith(f"{prefix}category"): await ctx.respond(embed=makeEmbed(title=getMsg("dm_title", ctx.guild), description=getMsg("dm_description", ctx.guild), color=strToColor(config["color_error"])))
#=========================================================================================================================
gotCommand(message)
#=========================================================================================================================
fullcmd = message.content.split() channel = client.create_group("channel", "Commands related to parent voice channel")
if message.guild is not None: @channel.command(name="set", description="Select the voice channel that will be parent to private ones")
async def channel_set(ctx: ApplicationContext, channel: Option(discord.VoiceChannel, "Parent Voice Channel")): # type: ignore
if message.author.guild_permissions.administrator: config = loadJson("config.json")
if ctx.guild is not None:
try: guildConfSet(ctx.guild, "channel", channel.id)
await ctx.respond(embed=makeEmbed(title=getMsg("set_channel_title", ctx.guild), description=getMsg("set_channel_description", ctx.guild).format(channel.name), color=strToColor(config["color_ok"])))
if fullcmd[1] == "reset": if guildConfGet(ctx.guild, "category") is None:
await ctx.respond(embed=makeEmbed(title=getMsg("hint_none_category_title", ctx.guild), description=getMsg("hint_none_category_description", ctx.guild), color=strToColor(config["color_warn"])))
if guildConfGet(message.guild, "category") is not None: else:
await ctx.respond(embed=makeEmbed(title=getMsg("dm_title", ctx.guild), description=getMsg("dm_description", ctx.guild), color=strToColor(config["color_error"])))
guildConfReset(message.guild, "category")
@channel.command(name="reset", description="Reset the currently selected parent voice channel")
await message.reply(embed=makeEmbed(title=getMsg("reset_category_title", message.guild), description=getMsg("reset_category_description", message.guild).format(prefix), color=strToColor(config["color_ok"])), mention_author=False) async def channel_reset(ctx: ApplicationContext): # type: ignore
config = loadJson("config.json")
else: if ctx.guild is not None:
if guildConfGet(ctx.guild, "channel") is not None:
await message.reply(embed=makeEmbed(title=getMsg("hint_none_category_title", message.guild), description=getMsg("hint_none_category_description", message.guild).format(prefix), color=strToColor(config["color_warn"])), mention_author=False) guildConfReset(ctx.guild, "channel")
await ctx.respond(embed=makeEmbed(title=getMsg("reset_channel_title", ctx.guild), description=getMsg("reset_channel_description", ctx.guild), color=strToColor(config["color_ok"])))
else:
selected_category = discord.utils.get(message.guild.channels, id=int(fullcmd[1]))
guildConfSet(message.guild, "category", int(fullcmd[1]))
await message.reply(embed=makeEmbed(title=getMsg("set_category_title", message.guild), description=getMsg("set_category_description", message.guild).format(selected_category.name), color=strToColor(config["color_ok"])), mention_author=False)
if guildConfGet(message.guild, "channel") is None:
await message.channel.send(embed=makeEmbed(title=getMsg("hint_none_channel_title", message.guild), description=getMsg("hint_none_channel_description", message.guild).format(prefix), color=strToColor(config["color_warn"])))
except Exception as exp:
if debug:
print(exp)
await message.reply(embed=makeEmbed(title=getMsg("error_category_title", message.guild), description=getMsg("error_category_description", message.guild).format(prefix), footer=getMsg("help_notice_id_category", message.guild), color=strToColor(config["color_error"])), mention_author=False)
else:
await message.reply(embed=makeEmbed(title=getMsg("forbidden_title", message.guild), description=getMsg("forbidden_description", message.guild), color=strToColor(config["color_error"])), mention_author=False)
else: else:
await message.reply(embed=makeEmbed(title=getMsg("dm_title", message.guild), description=getMsg("dm_description", message.guild), color=strToColor(config["color_error"])), mention_author=False) await ctx.respond(embed=makeEmbed(title=getMsg("hint_none_channel_title", ctx.guild), description=getMsg("hint_none_channel_description", ctx.guild), color=strToColor(config["color_warn"])))
else:
await ctx.respond(embed=makeEmbed(title=getMsg("dm_title", ctx.guild), description=getMsg("dm_description", ctx.guild), color=strToColor(config["color_error"])))
#=========================================================================================================================
elif message.content.startswith(f"{prefix}prefix"): #=========================================================================================================================
category = client.create_group("category", "Commands related to parent channels category")
gotCommand(message)
@category.command(name="set", description="Select the voice channel that will be parent to private ones")
fullcmd = message.content.split() async def category_set(ctx: ApplicationContext, category: Option(discord.CategoryChannel, "Parent Channel Category")): # type: ignore
config = loadJson("config.json")
if message.guild is not None: if ctx.guild is not None:
guildConfSet(ctx.guild, "category", category.id)
if message.author.guild_permissions.administrator: await ctx.respond(embed=makeEmbed(title=getMsg("set_category_title", ctx.guild), description=getMsg("set_category_description", ctx.guild).format(category.name), color=strToColor(config["color_ok"])))
if guildConfGet(ctx.guild, "channel") is None:
try: await ctx.respond(embed=makeEmbed(title=getMsg("hint_none_channel_title", ctx.guild), description=getMsg("hint_none_channel_description", ctx.guild), color=strToColor(config["color_warn"])))
else:
if fullcmd[1] == "reset": await ctx.respond(embed=makeEmbed(title=getMsg("dm_title", ctx.guild), description=getMsg("dm_description", ctx.guild), color=strToColor(config["color_error"])))
if guildConfGet(message.guild, "prefix") is not None: @category.command(name="reset", description="Reset the currently selected parent channel category")
async def category_reset(ctx: ApplicationContext): # type: ignore
guildConfReset(message.guild, "prefix") config = loadJson("config.json")
if ctx.guild is not None:
await message.reply(embed=makeEmbed(title=getMsg("reset_prefix_title", message.guild), description=getMsg("reset_prefix_description", message.guild).format(config["bot_prefix"], config["bot_prefix"]), color=strToColor(config["color_ok"])), mention_author=False) if guildConfGet(ctx.guild, "category") is not None:
guildConfReset(ctx.guild, "category")
else: await ctx.respond(embed=makeEmbed(title=getMsg("reset_category_title", ctx.guild), description=getMsg("reset_category_description", ctx.guild), color=strToColor(config["color_ok"])))
await message.reply(embed=makeEmbed(title=getMsg("hint_none_prefix_title", message.guild), description=getMsg("hint_none_prefix_description", message.guild).format(prefix, prefix), color=strToColor(config["color_warn"])), mention_author=False)
else:
guildConfSet(message.guild, "prefix", fullcmd[1])
await message.reply(embed=makeEmbed(title=getMsg("set_prefix_title", message.guild), description=getMsg("set_prefix_description", message.guild).format(fullcmd[1]), color=strToColor(config["color_ok"])), mention_author=False)
except:
await message.reply(embed=makeEmbed(title=getMsg("error_prefix_title", message.guild), description=getMsg("error_prefix_description", message.guild).format(prefix), color=strToColor(config["color_error"])), mention_author=False)
else:
await message.reply(embed=makeEmbed(title=getMsg("forbidden_title", message.guild), description=getMsg("forbidden_description", message.guild), color=strToColor(config["color_error"])), mention_author=False)
else: else:
await message.reply(embed=makeEmbed(title=getMsg("dm_title", message.guild), description=getMsg("dm_description", message.guild), color=strToColor(config["color_error"])), mention_author=False) await ctx.respond(embed=makeEmbed(title=getMsg("hint_none_category_title", ctx.guild), description=getMsg("hint_none_category_description", ctx.guild), color=strToColor(config["color_warn"])))
else:
elif message.content.startswith(f"{prefix}locale"): await ctx.respond(embed=makeEmbed(title=getMsg("dm_title", ctx.guild), description=getMsg("dm_description", ctx.guild), color=strToColor(config["color_error"])))
#=========================================================================================================================
gotCommand(message)
fullcmd = message.content.split()
if message.guild is not None:
if message.author.guild_permissions.administrator:
try:
if fullcmd[1] == "reset":
if guildConfGet(message.guild, "locale") is not None:
guildConfReset(message.guild, "locale")
appendLog(f"Server's locale has been reset", message.guild)
await message.reply(embed=makeEmbed(title=getMsg("reset_locale_title", message.guild), description=getMsg("reset_locale_description", message.guild).format(getMsg("locale_name", message.guild), prefix), color=strToColor(config["color_ok"])), mention_author=False)
else:
await message.reply(embed=makeEmbed(title=getMsg("hint_none_locale_title", message.guild), description=getMsg("hint_none_locale_description", message.guild).format(getMsg("locale_name", message.guild), prefix), color=strToColor(config["color_warn"])), mention_author=False)
else:
for locale_file in os.listdir(f"{path}/locale/"):
if locale_file[:-5] == fullcmd[1]:
guildConfSet(message.guild, "locale", fullcmd[1])
appendLog(f"Server's locale is now set to {fullcmd[1]}", message.guild)
await message.reply(embed=makeEmbed(title=getMsg("set_locale_title", message.guild), description=getMsg("set_locale_description", message.guild).format(getMsg("locale_name", message.guild)), color=strToColor(config["color_ok"])), mention_author=False)
return
locales = []
for locale_file in os.listdir(f"{path}/locale/"):
locales.append(f"`{locale_file[:-5]}`")
await message.reply(embed=makeEmbed(title=getMsg("error_locale_title", message.guild), description=getMsg("error_locale_description", message.guild).format(prefix, ", ".join(locales)), color=strToColor(config["color_error"])), mention_author=False)
except:
locales = []
for locale_file in os.listdir(f"{path}/locale/"):
locales.append(f"`{locale_file[:-5]}`")
await message.reply(embed=makeEmbed(title=getMsg("error_locale_title", message.guild), description=getMsg("error_locale_description", message.guild).format(prefix, ", ".join(locales)), color=strToColor(config["color_error"])), mention_author=False)
else:
await message.reply(embed=makeEmbed(title=getMsg("forbidden_title", message.guild), description=getMsg("forbidden_description", message.guild), color=strToColor(config["color_error"])), mention_author=False)
else:
await message.reply(embed=makeEmbed(title=getMsg("dm_title", message.guild), description=getMsg("dm_description", message.guild), color=strToColor(config["color_error"])), mention_author=False)
elif message.content.startswith(f"{prefix}help"):
gotCommand(message)
await message.reply(embed=getHelpMessage(message, version, prefix=prefix), mention_author=False)
#if loadJson("config.json")["auto_clear_trash"]:
# run func
appendLog(f"Trying to log in...") appendLog(f"Trying to log in...")
client.run(loadJson("config.json")["bot_token"])
client.run(loadJson("config.json")["bot_token"])