From 4362d5cac414fb093f591c9e0618d6e3565f2148 Mon Sep 17 00:00:00 2001 From: Profitroll Date: Thu, 10 Feb 2022 21:26:16 +0200 Subject: [PATCH] Update 1.3 --- functions.py | 6 +++++- locale/en.json | 3 ++- locale/ru.json | 3 ++- locale/uk.json | 3 ++- start.bat | 3 +++ start.sh | 2 ++ yusarin.py | 24 ++++++++++++++++-------- 7 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 start.bat create mode 100644 start.sh diff --git a/functions.py b/functions.py index bb94baf..f841739 100644 --- a/functions.py +++ b/functions.py @@ -17,7 +17,7 @@ log_size = 512 debug = False try: - with open(filename, 'r', encoding="utf-8") as json_file: + with open("config.json", 'r', encoding="utf-8") as json_file: output = json.load(json_file) json_file.close() debug = output["debug"] @@ -152,6 +152,10 @@ def getMsg(string, guild=None): appendLog(f"Could not get locale string named {string} due to exception {exp}", guild) return f"Could not get locale string {string}" +def getEmbed(string, guild=None): + # Feature coming soon + pass + def isUserVoice(vc): global path try: diff --git a/locale/en.json b/locale/en.json index 9d1db52..b1ebfb8 100644 --- a/locale/en.json +++ b/locale/en.json @@ -16,6 +16,7 @@ "result_prefix": "Command prefix **{0}** is now set as primary for this server", "warn_channel": "⚠ Parent channel is not set!\nFor the bot to work, you need to set parent channel: `{0}channel CHANNEL-ID`", "warn_category": "⚠ Parent category is not set!\nFor the bot to work, you need to set parent category: `{0}category CATEGORY-ID`", + "warn_text_channel": "⚠ Selected channel is a text channel!\nPlease, use an ID of the voice channel instead.", "reset_channel": "Parent voice channel has been reset", "reset_category": "Parent category has been reset", "reset_prefix": "Commands prefix has been reset and now is `{0}`", @@ -35,4 +36,4 @@ "name_nomic": "no-mic-{0}", "description_nomic": "Text channel for no mic communication\nVoice room ID: {0}" } -} \ No newline at end of file +} diff --git a/locale/ru.json b/locale/ru.json index fed3a07..d000b37 100644 --- a/locale/ru.json +++ b/locale/ru.json @@ -16,6 +16,7 @@ "result_prefix": "Префикс `{0}` был установлен как основной для этого сервера", "warn_channel": "⚠ Родительский канал не установлен!\nДля работы бота нужно установить канал: `{0}channel ID-КАНАЛА`", "warn_category": "⚠ Родительская категория не установлена!\nДля работы бота нужно установить категорию: `{0}category ID-КАТЕГОРИИ`", + "warn_text_channel": "⚠ Выбранный канал является текстовым!\nПожалуйста, укажите ID голосового канала.", "reset_channel": "Родительский голосовой канал был сброшен", "reset_category": "Родительская категория была сброшена", "reset_prefix": "Прификс команд был сброшен, теперь это `{0}`", @@ -35,4 +36,4 @@ "name_nomic": "без-микро-{0}", "description_nomic": "Текстовый канал для коммуникации без микрофона\nID голосовой комнаты: {0}" } -} \ No newline at end of file +} diff --git a/locale/uk.json b/locale/uk.json index d7de74f..0d09891 100644 --- a/locale/uk.json +++ b/locale/uk.json @@ -16,6 +16,7 @@ "result_prefix": "Префікс **{0}** було встановлено як основний для цього сервера", "warn_channel": "⚠ Твірний канал не встановлено!\nДля роботи робота потрібно встановити канал: `{0}channel ID-КАНАЛА`", "warn_category": "⚠ Твірна категорія не встановлена!\nДля роботи робота потрібно встановити категорію: `{0}category ID-КАТЕГОРІЇ`", + "warn_text_channel": "⚠ Обраний канал є текстовим!\nБудь ласка, вкажіть ID голосового каналу.", "reset_channel": "Твірний голосовий канал було скинуто", "reset_category": "Твірну категорію було скинуто", "reset_prefix": "Префікс команд було скинуто, тепер це `{0}`", @@ -35,4 +36,4 @@ "name_nomic": "без-мікро-{0}", "description_nomic": "Текстовий канал для комунікації без мікрофона\nID голосової кімнати: {0}" } -} \ No newline at end of file +} diff --git a/start.bat b/start.bat new file mode 100644 index 0000000..85a3f29 --- /dev/null +++ b/start.bat @@ -0,0 +1,3 @@ +title YusarinBot +cls +python3 yusarin.py \ No newline at end of file diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..db52445 --- /dev/null +++ b/start.sh @@ -0,0 +1,2 @@ +#!/bin/sh +python3 yusarin.py \ No newline at end of file diff --git a/yusarin.py b/yusarin.py index 202ff86..4a5e2f7 100644 --- a/yusarin.py +++ b/yusarin.py @@ -13,7 +13,7 @@ except Exception as exp: from functions import * pid = os.getpid() -version = 1.2 +version = 1.3 if loadJson("config.json")["check_for_updates"]: try: @@ -164,18 +164,26 @@ async def on_message(message): 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])) + guildConfSet(message.guild, "channel", int(fullcmd[1])) - await message.channel.send(getMsg("result_channel", message.guild).format(selected_channel.name)) + await message.channel.send(getMsg("result_channel", message.guild).format(selected_channel.name)) - if guildConfGet(message.guild, "category") is None: + if guildConfGet(message.guild, "category") is None: - await message.channel.send(getMsg("warn_category", message.guild).format(prefix)) - + await message.channel.send(getMsg("warn_category", message.guild).format(prefix)) + + else: + + print(type(selected_channel)) + + await message.channel.send(getMsg("warn_text_channel", message.guild)) + except Exception as exp: - #print(exp) + print(exp) await message.channel.send(getMsg("usage_channel", message.guild).format(prefix)) @@ -350,4 +358,4 @@ async def on_message(message): appendLog(f"Trying to log in...") -client.run(loadJson("config.json")["bot_token"]) \ No newline at end of file +client.run(loadJson("config.json")["bot_token"])