Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
4362d5cac4 | |||
|
f52f9c2281 | ||
9e19c28b82 |
@@ -26,6 +26,7 @@ Installation instructions are listed below. Please, make sure you have installed
|
||||
12. Bot is ready! Run it using `python yusarin.py`
|
||||
|
||||
## Config explanation
|
||||
- "debug" - Option that enabled more detailed log messages [Boolean]
|
||||
- "owner" - Discord ID of user who will be able to execute admin commands (`$shutdown` for example) [Integer]
|
||||
- "bot_name" - Name of your bot. Is not used anywhere yet [String]
|
||||
- "bot_token" - Token of your Discord bot [String]
|
||||
|
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"debug": false,
|
||||
"owner": SET-OWNER-ID,
|
||||
"bot_name": "Yusa Nishimori",
|
||||
"bot_token": "SET-BOT-TOKEN",
|
||||
|
114
functions.py
114
functions.py
@@ -11,6 +11,19 @@ path = Path(__file__).resolve().parent
|
||||
|
||||
log_size = 512
|
||||
|
||||
# This is the default option for "debug" key in
|
||||
# file config.json, so if cebug is not set in it
|
||||
# bot will use this value instead.
|
||||
debug = False
|
||||
|
||||
try:
|
||||
with open("config.json", 'r', encoding="utf-8") as json_file:
|
||||
output = json.load(json_file)
|
||||
json_file.close()
|
||||
debug = output["debug"]
|
||||
except:
|
||||
debug = debug
|
||||
|
||||
# Check latest log size
|
||||
def checkSize():
|
||||
global path
|
||||
@@ -34,12 +47,20 @@ def checkSize():
|
||||
pass
|
||||
|
||||
# Append string to log
|
||||
def appendLog(message, guild="none"):
|
||||
def appendLog(message, guild=None, announce=True):
|
||||
global debug
|
||||
global path
|
||||
|
||||
message_formatted = f'[{datetime.now().strftime("%d.%m.%Y")}] [{datetime.now().strftime("%H:%M:%S")}] [{str(guild)}] {message}'
|
||||
if guild == None:
|
||||
message_formatted = f'[{datetime.now().strftime("%d.%m.%Y")}] [{datetime.now().strftime("%H:%M:%S")}] {message}'
|
||||
else:
|
||||
if debug:
|
||||
message_formatted = f'[{datetime.now().strftime("%d.%m.%Y")}] [{datetime.now().strftime("%H:%M:%S")}] [{guild} | {str(guild.id)}] {message}'
|
||||
else:
|
||||
message_formatted = f'[{datetime.now().strftime("%d.%m.%Y")}] [{datetime.now().strftime("%H:%M:%S")}] [{guild}] {message}'
|
||||
|
||||
print(message_formatted)
|
||||
if announce:
|
||||
print(message_formatted)
|
||||
|
||||
checkSize()
|
||||
|
||||
@@ -53,50 +74,67 @@ def saveJson(value, filename):
|
||||
f.close()
|
||||
|
||||
def loadJson(filename):
|
||||
global debug
|
||||
try:
|
||||
with open(filename, 'r', encoding="utf-8") as json_file:
|
||||
output = json.load(json_file)
|
||||
json_file.close()
|
||||
except Exception as exp:
|
||||
appendLog(f"Could not get contents of json file {filename} due to exception {exp}")
|
||||
if debug:
|
||||
appendLog(f"Could not load json file {filename} due to exception {exp}")
|
||||
output = {}
|
||||
return output
|
||||
|
||||
def gotCommand(message):
|
||||
global debug
|
||||
if debug:
|
||||
appendLog(f"Command '{message.content}' from {message.author} ({str(message.author.id)})", message.guild)
|
||||
else:
|
||||
appendLog(f"Command '{message.content}' from {message.author}", message.guild)
|
||||
|
||||
def guildConfGet(guild, variable):
|
||||
global path
|
||||
config = loadJson(f"{path}/guilds/{str(guild)}/config.json")
|
||||
global debug
|
||||
try:
|
||||
config = loadJson(f"{path}/guilds/{str(guild.id)}/config.json")
|
||||
return config[variable]
|
||||
except:
|
||||
except Exception as exp:
|
||||
if debug:
|
||||
appendLog(f"Could not get guild config key '{variable}' due to {exp}", guild)
|
||||
return None
|
||||
|
||||
def guildConfSet(guild, variable, value):
|
||||
global path
|
||||
config = loadJson(f"{path}/guilds/{str(guild)}/config.json")
|
||||
config = loadJson(f"{path}/guilds/{str(guild.id)}/config.json")
|
||||
config[variable] = value
|
||||
try:
|
||||
saveJson(config, f"{path}/guilds/{str(guild)}/config.json")
|
||||
saveJson(config, f"{path}/guilds/{str(guild.id)}/config.json")
|
||||
except:
|
||||
os.mkdir(f"{path}/guilds/{str(guild)}")
|
||||
os.mkdir(f"{path}/guilds/{str(guild)}/channels")
|
||||
saveJson(config, f"{path}/guilds/{str(guild)}/config.json")
|
||||
os.mkdir(f"{path}/guilds/{str(guild.id)}")
|
||||
os.mkdir(f"{path}/guilds/{str(guild.id)}/channels")
|
||||
saveJson(config, f"{path}/guilds/{str(guild.id)}/config.json")
|
||||
appendLog(f"Guild config key '{variable}' is now set to '{value}'", guild)
|
||||
|
||||
def guildConfReset(guild, variable):
|
||||
global path
|
||||
config = loadJson(f"{path}/guilds/{str(guild)}/config.json")
|
||||
del config[variable]
|
||||
try:
|
||||
saveJson(config, f"{path}/guilds/{str(guild)}/config.json")
|
||||
except:
|
||||
os.mkdir(f"{path}/guilds/{str(guild)}")
|
||||
os.mkdir(f"{path}/guilds/{str(guild)}/channels")
|
||||
saveJson(config, f"{path}/guilds/{str(guild)}/config.json")
|
||||
config = loadJson(f"{path}/guilds/{str(guild.id)}/config.json")
|
||||
del config[variable]
|
||||
try:
|
||||
saveJson(config, f"{path}/guilds/{str(guild.id)}/config.json")
|
||||
except:
|
||||
os.mkdir(f"{path}/guilds/{str(guild.id)}")
|
||||
os.mkdir(f"{path}/guilds/{str(guild.id)}/channels")
|
||||
saveJson(config, f"{path}/guilds/{str(guild.id)}/config.json")
|
||||
appendLog(f"Guild config key '{variable}' has been reset", guild)
|
||||
except Exception as exp:
|
||||
appendLog(f"Could not reset guild config key '{variable}' due to {exp}", guild)
|
||||
|
||||
def guildLocaleGet(guild):
|
||||
global path
|
||||
config = loadJson(f"{path}/config.json")
|
||||
try:
|
||||
locale = guildConfGet(guild.id, "locale")
|
||||
locale = guildConfGet(guild, "locale")
|
||||
except:
|
||||
return config["bot_locale"]
|
||||
if locale is None:
|
||||
@@ -104,16 +142,20 @@ def guildLocaleGet(guild):
|
||||
else:
|
||||
return locale
|
||||
|
||||
def getMsg(string, guild):
|
||||
def getMsg(string, guild=None):
|
||||
global path
|
||||
config = loadJson("config.json")
|
||||
try:
|
||||
locale = loadJson(f'{path}/locale/{guildLocaleGet(guild)}.json')
|
||||
return locale["messages"][string]
|
||||
except Exception as exp:
|
||||
appendLog(f"Could not get locale string named {string} due to exception {exp}")
|
||||
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:
|
||||
@@ -127,6 +169,7 @@ def isUserVoice(vc):
|
||||
|
||||
async def removeUserVoice(vc):
|
||||
global path
|
||||
global debug
|
||||
channels_list = os.listdir(f"{path}/guilds/{str(vc.guild.id)}/channels/")
|
||||
if f"{vc.id}.json" in channels_list:
|
||||
vc_file = f"{path}/guilds/{str(vc.guild.id)}/channels/{str(vc.id)}.json"
|
||||
@@ -138,14 +181,21 @@ async def removeUserVoice(vc):
|
||||
os.remove(vc_file)
|
||||
|
||||
await needed_channel.delete()
|
||||
appendLog(f"Removed voice channel {str(needed_channel.id)} of user {str(vc_conf['ownerid'])}", guild=vc.guild.id)
|
||||
if debug:
|
||||
appendLog(f"Removed voice channel '{needed_channel}' ({str(needed_channel.id)}) of user with id {str(vc_conf['ownerid'])}", guild=vc.guild)
|
||||
else:
|
||||
appendLog(f"Removed voice channel '{needed_channel}' of user with id {str(vc_conf['ownerid'])}", guild=vc.guild)
|
||||
await nomic_channel.delete()
|
||||
appendLog(f"Removed nomic channel {str(nomic_channel.id)} of channel {str(needed_channel.id)}", guild=vc.guild.id)
|
||||
if debug:
|
||||
appendLog(f"Removed nomic channel {nomic_channel} ({str(nomic_channel.id)}) of channel with id {str(needed_channel.id)}", guild=vc.guild)
|
||||
else:
|
||||
appendLog(f"Removed nomic channel '{nomic_channel}' of channel with id {str(needed_channel.id)}", guild=vc.guild)
|
||||
else:
|
||||
return
|
||||
|
||||
async def createUserVoice(vc, category, member):
|
||||
global path
|
||||
global debug
|
||||
chan = {}
|
||||
overwrites_channel = {
|
||||
vc.guild.default_role: discord.PermissionOverwrite(view_channel=True),
|
||||
@@ -158,14 +208,20 @@ async def createUserVoice(vc, category, member):
|
||||
member: discord.PermissionOverwrite(read_messages=True, view_channel=True, manage_channels=True)
|
||||
}
|
||||
created_channel = await vc.guild.create_voice_channel(getMsg("name_voice", vc.guild).format(member.name), category=category, overwrites=overwrites_channel)
|
||||
appendLog(f"Created voice channel {str(created_channel.id)} for user {str(member.id)}", guild=vc.guild.id)
|
||||
if debug:
|
||||
appendLog(f"Created voice channel '{created_channel}' ({str(created_channel.id)}) for user {member} ({str(member.id)})", guild=vc.guild)
|
||||
else:
|
||||
appendLog(f"Created voice channel '{created_channel}' for user {member}", guild=vc.guild)
|
||||
if not os.path.isdir(f"{path}/guilds/{str(created_channel.guild.id)}/channels"):
|
||||
os.mkdir(f"{path}/guilds/{str(created_channel.guild.id)}/channels")
|
||||
vc_file = f"{path}/guilds/{str(created_channel.guild.id)}/channels/{str(created_channel.id)}.json"
|
||||
chan["ownerid"] = member.id
|
||||
saveJson(chan, vc_file)
|
||||
nomic_channel = await vc.guild.create_text_channel(getMsg("name_nomic", vc.guild).format(created_channel.id), category=category, overwrites=overwrites_nomic, topic=getMsg("description_nomic", vc.guild).format(str(created_channel.id)))
|
||||
appendLog(f"Created nomic channel {str(nomic_channel.id)} for channel {str(created_channel.id)}", guild=vc.guild.id)
|
||||
if debug:
|
||||
appendLog(f"Created nomic channel '{nomic_channel}' ({str(nomic_channel.id)}) for channel '{created_channel}' ({str(created_channel.id)})", guild=vc.guild)
|
||||
else:
|
||||
appendLog(f"Created nomic channel '{nomic_channel}' for channel '{created_channel}'", guild=vc.guild)
|
||||
chan["nomic"] = nomic_channel.id
|
||||
saveJson(chan, vc_file)
|
||||
return created_channel
|
||||
@@ -221,16 +277,16 @@ async def guildConfigured(guild):
|
||||
config = loadJson("config.json")
|
||||
|
||||
for kind in ["channel", "category", "prefix"]:
|
||||
if guildConfGet(guild.id, kind) is not None:
|
||||
if guildConfGet(guild, kind) is not None:
|
||||
try:
|
||||
if kind == "channel":
|
||||
guild_object = discord.utils.get(guild.channels, id=guildConfGet(guild.id, kind))
|
||||
guild_object = discord.utils.get(guild.channels, id=guildConfGet(guild, kind))
|
||||
output[kind] = getMsg("configured_"+kind, guild).format(guild_object.name)
|
||||
elif kind == "category":
|
||||
guild_object = discord.utils.get(guild.categories, id=guildConfGet(guild.id, kind))
|
||||
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.id, kind))
|
||||
output[kind] = getMsg("info_prefix", guild).format(guildConfGet(guild, kind))
|
||||
except Exception as exp:
|
||||
if kind == "prefix":
|
||||
output[kind] = getMsg("info_prefix", guild).format(config["bot_prefix"])
|
||||
|
@@ -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}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
117
yusarin.py
117
yusarin.py
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import shutil
|
||||
import requests
|
||||
import threading
|
||||
|
||||
@@ -12,7 +13,7 @@ except Exception as exp:
|
||||
|
||||
from functions import *
|
||||
pid = os.getpid()
|
||||
version = 1.1
|
||||
version = 1.3
|
||||
|
||||
if loadJson("config.json")["check_for_updates"]:
|
||||
try:
|
||||
@@ -37,10 +38,34 @@ async def on_ready():
|
||||
|
||||
await clearTrash(client)
|
||||
|
||||
@client.event
|
||||
async def on_guild_join(guild):
|
||||
|
||||
global path
|
||||
|
||||
os.mkdir(f"{path}/guilds/{str(guild.id)}")
|
||||
os.mkdir(f"{path}/guilds/{str(guild.id)}/channels")
|
||||
saveJson({}, f"{path}/guilds/{str(guild.id)}/config.json")
|
||||
|
||||
appendLog(f"Joined guild '{guild}' with id {str(guild.id)}")
|
||||
|
||||
@client.event
|
||||
async def on_guild_remove(guild):
|
||||
|
||||
global path
|
||||
|
||||
try:
|
||||
shutil.rmtree(f"{path}/guilds/{str(guild.id)}")
|
||||
except:
|
||||
pass
|
||||
|
||||
appendLog(f"Left guild '{guild}' with id {str(guild.id)}")
|
||||
|
||||
@client.event
|
||||
async def on_voice_state_update(member, before, after):
|
||||
|
||||
global debug
|
||||
|
||||
config = loadJson("config.json")
|
||||
|
||||
vc_from = before.channel
|
||||
@@ -64,15 +89,18 @@ async def on_voice_state_update(member, before, after):
|
||||
await changeNomicPerms("deny", vc_from, member)
|
||||
if isUserVoice(vc_to):
|
||||
await changeNomicPerms("allow", vc_to, member)
|
||||
if vc_to.id == guildConfGet(vc_to.guild.id, "channel"):
|
||||
if guildConfGet(vc_to.guild.id, "category") is not None:
|
||||
voice_chan = await createUserVoice(vc_to, discord.utils.get(vc_to.guild.categories, id=guildConfGet(vc_to.guild.id, "category")), member)
|
||||
if vc_to.id == guildConfGet(vc_to.guild, "channel"):
|
||||
if guildConfGet(vc_to.guild, "category") is not None:
|
||||
voice_chan = await createUserVoice(vc_to, discord.utils.get(vc_to.guild.categories, id=guildConfGet(vc_to.guild, "category")), member)
|
||||
try:
|
||||
await member.move_to(voice_chan)
|
||||
except:
|
||||
await removeUserVoice(voice_chan)
|
||||
else:
|
||||
appendLog(f"Category for guild {str(vc_to.guild.id)} is not set", guild=vc_to.guild.id)
|
||||
if debug:
|
||||
appendLog(f"Category for guild {vc_to.guild} ({str(vc_to.guild.id)}) is not set", guild=vc_to.guild)
|
||||
else:
|
||||
appendLog(f"Category for guild {vc_to.guild} is not set", guild=vc_to.guild)
|
||||
|
||||
# ==========================================================================================
|
||||
|
||||
@@ -83,7 +111,7 @@ async def on_message(message):
|
||||
|
||||
if message.guild is not None:
|
||||
try:
|
||||
prefix = guildConfGet(message.guild.id, "prefix")
|
||||
prefix = guildConfGet(message.guild, "prefix")
|
||||
if prefix is None:
|
||||
prefix = config["bot_prefix"]
|
||||
except Exception as exp:
|
||||
@@ -98,6 +126,8 @@ async def on_message(message):
|
||||
|
||||
if message.content in [f"{prefix}reboot", f"{prefix}restart", f"{prefix}shutdown", f"{prefix}die"]:
|
||||
|
||||
gotCommand(message)
|
||||
|
||||
if message.author.id == config["owner"]:
|
||||
|
||||
await message.channel.send(getMsg("shutdown", message.guild))
|
||||
@@ -109,6 +139,8 @@ async def on_message(message):
|
||||
|
||||
elif message.content.startswith(f"{prefix}channel"):
|
||||
|
||||
gotCommand(message)
|
||||
|
||||
fullcmd = message.content.split()
|
||||
|
||||
if message.guild is not None:
|
||||
@@ -119,9 +151,9 @@ async def on_message(message):
|
||||
|
||||
if fullcmd[1] == "reset":
|
||||
|
||||
if guildConfGet(message.guild.id, "channel") is not None:
|
||||
if guildConfGet(message.guild, "channel") is not None:
|
||||
|
||||
guildConfReset(message.guild.id, "channel")
|
||||
guildConfReset(message.guild, "channel")
|
||||
|
||||
await message.channel.send(getMsg("reset_channel", message.guild))
|
||||
|
||||
@@ -132,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.id, "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.id, "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))
|
||||
|
||||
@@ -152,10 +192,12 @@ async def on_message(message):
|
||||
await message.channel.send(getMsg("command_forbidden", message.guild))
|
||||
|
||||
else:
|
||||
await message.channel.send(getMsg("command_in_dm", message.guild))
|
||||
await message.channel.send(getMsg("command_in_dm"))
|
||||
|
||||
elif message.content.startswith(f"{prefix}category"):
|
||||
|
||||
gotCommand(message)
|
||||
|
||||
fullcmd = message.content.split()
|
||||
|
||||
if message.guild is not None:
|
||||
@@ -166,9 +208,9 @@ async def on_message(message):
|
||||
|
||||
if fullcmd[1] == "reset":
|
||||
|
||||
if guildConfGet(message.guild.id, "category") is not None:
|
||||
if guildConfGet(message.guild, "category") is not None:
|
||||
|
||||
guildConfReset(message.guild.id, "category")
|
||||
guildConfReset(message.guild, "category")
|
||||
|
||||
await message.channel.send(getMsg("reset_category", message.guild))
|
||||
|
||||
@@ -180,11 +222,11 @@ async def on_message(message):
|
||||
|
||||
selected_category = discord.utils.get(message.guild.channels, id=int(fullcmd[1]))
|
||||
|
||||
guildConfSet(message.guild.id, "category", int(fullcmd[1]))
|
||||
guildConfSet(message.guild, "category", int(fullcmd[1]))
|
||||
|
||||
await message.channel.send(getMsg("result_category", message.guild).format(selected_category.name))
|
||||
|
||||
if guildConfGet(message.guild.id, "channel") is None:
|
||||
if guildConfGet(message.guild, "channel") is None:
|
||||
|
||||
await message.channel.send(getMsg("warn_channel", message.guild).format(prefix))
|
||||
|
||||
@@ -199,10 +241,12 @@ async def on_message(message):
|
||||
await message.channel.send(getMsg("command_forbidden", message.guild))
|
||||
|
||||
else:
|
||||
await message.channel.send(getMsg("command_in_dm", message.guild))
|
||||
await message.channel.send(getMsg("command_in_dm"))
|
||||
|
||||
elif message.content.startswith(f"{prefix}prefix"):
|
||||
|
||||
gotCommand(message)
|
||||
|
||||
fullcmd = message.content.split()
|
||||
|
||||
if message.guild is not None:
|
||||
@@ -213,9 +257,9 @@ async def on_message(message):
|
||||
|
||||
if fullcmd[1] == "reset":
|
||||
|
||||
if guildConfGet(message.guild.id, "prefix") is not None:
|
||||
if guildConfGet(message.guild, "prefix") is not None:
|
||||
|
||||
guildConfReset(message.guild.id, "prefix")
|
||||
guildConfReset(message.guild, "prefix")
|
||||
|
||||
await message.channel.send(getMsg("reset_prefix", message.guild).format(config["bot_prefix"]))
|
||||
|
||||
@@ -225,7 +269,7 @@ async def on_message(message):
|
||||
|
||||
else:
|
||||
|
||||
guildConfSet(message.guild.id, "prefix", fullcmd[1])
|
||||
guildConfSet(message.guild, "prefix", fullcmd[1])
|
||||
|
||||
await message.channel.send(getMsg("result_prefix", message.guild).format(fullcmd[1]))
|
||||
|
||||
@@ -237,10 +281,12 @@ async def on_message(message):
|
||||
await message.channel.send(getMsg("command_forbidden", message.guild))
|
||||
|
||||
else:
|
||||
await message.channel.send(getMsg("command_in_dm", message.guild))
|
||||
await message.channel.send(getMsg("command_in_dm"))
|
||||
|
||||
elif message.content.startswith(f"{prefix}locale"):
|
||||
|
||||
gotCommand(message)
|
||||
|
||||
fullcmd = message.content.split()
|
||||
|
||||
if message.guild is not None:
|
||||
@@ -251,10 +297,10 @@ async def on_message(message):
|
||||
|
||||
if fullcmd[1] == "reset":
|
||||
|
||||
if guildConfGet(message.guild.id, "locale") is not None:
|
||||
if guildConfGet(message.guild, "locale") is not None:
|
||||
|
||||
guildConfReset(message.guild.id, "locale")
|
||||
appendLog(f"Server's locale has been reset", message.guild.id)
|
||||
guildConfReset(message.guild, "locale")
|
||||
appendLog(f"Server's locale has been reset", message.guild)
|
||||
await message.channel.send(getMsg("reset_locale", message.guild).format(getMsg("locale_name", message.guild)))
|
||||
|
||||
else:
|
||||
@@ -265,8 +311,8 @@ async def on_message(message):
|
||||
|
||||
for locale_file in os.listdir(f"{path}/locale/"):
|
||||
if locale_file[:-5] == fullcmd[1]:
|
||||
guildConfSet(message.guild.id, "locale", fullcmd[1])
|
||||
appendLog(f"Server's locale is now set to {fullcmd[1]}", message.guild.id)
|
||||
guildConfSet(message.guild, "locale", fullcmd[1])
|
||||
appendLog(f"Server's locale is now set to {fullcmd[1]}", message.guild)
|
||||
await message.channel.send(getMsg("locale_set", message.guild))
|
||||
return
|
||||
|
||||
@@ -290,23 +336,26 @@ async def on_message(message):
|
||||
await message.channel.send(getMsg("command_forbidden", message.guild))
|
||||
|
||||
else:
|
||||
await message.channel.send(getMsg("command_in_dm", message.guild))
|
||||
await message.channel.send(getMsg("command_in_dm"))
|
||||
|
||||
elif message.content.startswith(f"{prefix}help"):
|
||||
|
||||
gotCommand(message)
|
||||
|
||||
if message.author.id == config["owner"]:
|
||||
if message.guild is not None:
|
||||
await message.channel.send(await guildConfigured(message.guild) + getMsg("help", message.guild).format(getMsg("help_owner", message.guild).format(prefix), prefix, prefix, prefix, prefix, prefix))
|
||||
else:
|
||||
await message.channel.send(getMsg("help", message.guild).format(getMsg("help_owner", message.guild).format(prefix), prefix, prefix, prefix, prefix, prefix))
|
||||
await message.channel.send(getMsg("help").format(getMsg("help_owner").format(prefix), prefix, prefix, prefix, prefix, prefix))
|
||||
else:
|
||||
if message.guild is not None:
|
||||
await message.channel.send(await guildConfigured(message.guild) + getMsg("help").format("", prefix, prefix, prefix, prefix))
|
||||
await message.channel.send(await guildConfigured(message.guild) + getMsg("help", message.guild).format("", prefix, prefix, prefix, prefix))
|
||||
else:
|
||||
await message.channel.send(getMsg("help", message.guild).format("", prefix, prefix, prefix, prefix))
|
||||
await message.channel.send(getMsg("help").format("", prefix, prefix, prefix, prefix))
|
||||
|
||||
#if loadJson("config.json")["auto_clear_trash"]:
|
||||
# run func
|
||||
|
||||
appendLog(f"Trying to log in...")
|
||||
|
||||
client.run(loadJson("config.json")["bot_token"])
|
||||
client.run(loadJson("config.json")["bot_token"])
|
||||
|
Reference in New Issue
Block a user