Update 1.7

This commit is contained in:
Profitroll 2022-08-03 10:11:04 +02:00
parent 078eac1446
commit 462f4c7a09
3 changed files with 31 additions and 22 deletions

View File

@ -10,6 +10,7 @@
"color_ok": "#226699", "color_ok": "#226699",
"color_warn": "#FFCC4D", "color_warn": "#FFCC4D",
"color_error": "#DD2E44", "color_error": "#DD2E44",
"enable_nomic": false,
"bot_site": "https://www.end-play.xyz/yusarin", "bot_site": "https://www.end-play.xyz/yusarin",
"bot_icon": "https://www.end-play.xyz/yusarin/logo", "bot_icon": "https://www.end-play.xyz/yusarin/logo",
"check_for_updates": true, "check_for_updates": true,

View File

@ -61,7 +61,7 @@ def appendLog(message, guild=None, announce=True):
message_formatted = f'[{datetime.now().strftime("%d.%m.%Y")}] [{datetime.now().strftime("%H:%M:%S")}] [{guild}] {message}' message_formatted = f'[{datetime.now().strftime("%d.%m.%Y")}] [{datetime.now().strftime("%H:%M:%S")}] [{guild}] {message}'
if announce: if announce:
print(message_formatted) print(message_formatted, flush=True)
checkSize() checkSize()
@ -216,6 +216,7 @@ async def removeUserVoice(vc):
vc_conf = loadJson(vc_file) vc_conf = loadJson(vc_file)
needed_channel = discord.utils.get(vc.guild.channels, id=vc.id) needed_channel = discord.utils.get(vc.guild.channels, id=vc.id)
if loadJson("config.json")["enable_nomic"]:
nomic_channel = discord.utils.get(vc.guild.channels, id=vc_conf["nomic"]) nomic_channel = discord.utils.get(vc.guild.channels, id=vc_conf["nomic"])
os.remove(vc_file) os.remove(vc_file)
@ -225,6 +226,8 @@ async def removeUserVoice(vc):
appendLog(f"Removed voice channel '{needed_channel}' ({str(needed_channel.id)}) of user with id {str(vc_conf['ownerid'])}", guild=vc.guild) appendLog(f"Removed voice channel '{needed_channel}' ({str(needed_channel.id)}) of user with id {str(vc_conf['ownerid'])}", guild=vc.guild)
else: else:
appendLog(f"Removed voice channel '{needed_channel}' of user with id {str(vc_conf['ownerid'])}", guild=vc.guild) appendLog(f"Removed voice channel '{needed_channel}' of user with id {str(vc_conf['ownerid'])}", guild=vc.guild)
if loadJson("config.json")["enable_nomic"]:
await nomic_channel.delete() await nomic_channel.delete()
if debug: if debug:
appendLog(f"Removed nomic channel {nomic_channel} ({str(nomic_channel.id)}) of channel with id {str(needed_channel.id)}", guild=vc.guild) appendLog(f"Removed nomic channel {nomic_channel} ({str(nomic_channel.id)}) of channel with id {str(needed_channel.id)}", guild=vc.guild)
@ -257,6 +260,7 @@ async def createUserVoice(vc, category, member):
vc_file = f"{path}/guilds/{str(created_channel.guild.id)}/channels/{str(created_channel.id)}.json" vc_file = f"{path}/guilds/{str(created_channel.guild.id)}/channels/{str(created_channel.id)}.json"
chan["ownerid"] = member.id chan["ownerid"] = member.id
saveJson(chan, vc_file) saveJson(chan, vc_file)
if loadJson("config.json")["enable_nomic"]:
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))) 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)))
if debug: if debug:
appendLog(f"Created nomic channel '{nomic_channel}' ({str(nomic_channel.id)}) for channel '{created_channel}' ({str(created_channel.id)})", guild=vc.guild) appendLog(f"Created nomic channel '{nomic_channel}' ({str(nomic_channel.id)}) for channel '{created_channel}' ({str(created_channel.id)})", guild=vc.guild)
@ -279,6 +283,7 @@ async def changeNomicPerms(mode, vc, member):
global path global path
vc_file = f"{path}/guilds/{str(vc.guild.id)}/channels/{str(vc.id)}.json" vc_file = f"{path}/guilds/{str(vc.guild.id)}/channels/{str(vc.id)}.json"
vc_conf = loadJson(vc_file) vc_conf = loadJson(vc_file)
if loadJson("config.json")["enable_nomic"]:
nomic_channel = discord.utils.get(vc.guild.channels, id=vc_conf["nomic"]) nomic_channel = discord.utils.get(vc.guild.channels, id=vc_conf["nomic"])
if mode == "deny": if mode == "deny":
await nomic_channel.set_permissions(member, view_channel=False) await nomic_channel.set_permissions(member, view_channel=False)

View File

@ -83,6 +83,7 @@ async def on_voice_state_update(member, before, after):
await removeUserVoice(vc_from) await removeUserVoice(vc_from)
return return
else: else:
if loadJson("config.json")["enable_nomic"]:
await changeNomicPerms("deny", vc_from, member) await changeNomicPerms("deny", vc_from, member)
# If user joined vc # If user joined vc
@ -91,8 +92,10 @@ async def on_voice_state_update(member, before, after):
if isVoiceOfUser(vc_from, member): if isVoiceOfUser(vc_from, member):
await removeUserVoice(vc_from) await removeUserVoice(vc_from)
else: else:
if loadJson("config.json")["enable_nomic"]:
await changeNomicPerms("deny", vc_from, member) await changeNomicPerms("deny", vc_from, member)
if isUserVoice(vc_to): if isUserVoice(vc_to):
if loadJson("config.json")["enable_nomic"]:
await changeNomicPerms("allow", vc_to, member) await changeNomicPerms("allow", vc_to, member)
if vc_to.id == guildConfGet(vc_to.guild, "channel"): if vc_to.id == guildConfGet(vc_to.guild, "channel"):
if guildConfGet(vc_to.guild, "category") is not None: if guildConfGet(vc_to.guild, "category") is not None: