Update 1.7
This commit is contained in:
43
functions.py
43
functions.py
@@ -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}'
|
||||
|
||||
if announce:
|
||||
print(message_formatted)
|
||||
print(message_formatted, flush=True)
|
||||
|
||||
checkSize()
|
||||
|
||||
@@ -216,7 +216,8 @@ async def removeUserVoice(vc):
|
||||
vc_conf = loadJson(vc_file)
|
||||
|
||||
needed_channel = discord.utils.get(vc.guild.channels, id=vc.id)
|
||||
nomic_channel = discord.utils.get(vc.guild.channels, id=vc_conf["nomic"])
|
||||
if loadJson("config.json")["enable_nomic"]:
|
||||
nomic_channel = discord.utils.get(vc.guild.channels, id=vc_conf["nomic"])
|
||||
|
||||
os.remove(vc_file)
|
||||
|
||||
@@ -225,11 +226,13 @@ 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)
|
||||
else:
|
||||
appendLog(f"Removed voice channel '{needed_channel}' of user with id {str(vc_conf['ownerid'])}", guild=vc.guild)
|
||||
await nomic_channel.delete()
|
||||
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)
|
||||
|
||||
if loadJson("config.json")["enable_nomic"]:
|
||||
await nomic_channel.delete()
|
||||
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
|
||||
|
||||
@@ -257,13 +260,14 @@ async def createUserVoice(vc, category, member):
|
||||
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)))
|
||||
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)
|
||||
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)))
|
||||
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
|
||||
|
||||
def isVoiceOfUser(vc, member):
|
||||
@@ -279,11 +283,12 @@ async def changeNomicPerms(mode, vc, member):
|
||||
global path
|
||||
vc_file = f"{path}/guilds/{str(vc.guild.id)}/channels/{str(vc.id)}.json"
|
||||
vc_conf = loadJson(vc_file)
|
||||
nomic_channel = discord.utils.get(vc.guild.channels, id=vc_conf["nomic"])
|
||||
if mode == "deny":
|
||||
await nomic_channel.set_permissions(member, view_channel=False)
|
||||
else:
|
||||
await nomic_channel.set_permissions(member, view_channel=True)
|
||||
if loadJson("config.json")["enable_nomic"]:
|
||||
nomic_channel = discord.utils.get(vc.guild.channels, id=vc_conf["nomic"])
|
||||
if mode == "deny":
|
||||
await nomic_channel.set_permissions(member, view_channel=False)
|
||||
else:
|
||||
await nomic_channel.set_permissions(member, view_channel=True)
|
||||
|
||||
async def clearTrash(client):
|
||||
global path
|
||||
|
Reference in New Issue
Block a user