Compare commits

..

No commits in common. "0379d99e693eae6535481927ce84948ad1e66e88" and "078eac1446f85969aefe8c530dffb94454cb251b" have entirely different histories.

3 changed files with 24 additions and 33 deletions

View File

@ -10,7 +10,6 @@
"color_ok": "#226699",
"color_warn": "#FFCC4D",
"color_error": "#DD2E44",
"enable_nomic": false,
"bot_site": "https://www.end-play.xyz/yusarin",
"bot_icon": "https://www.end-play.xyz/yusarin/logo",
"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}'
if announce:
print(message_formatted, flush=True)
print(message_formatted)
checkSize()
@ -216,8 +216,7 @@ async def removeUserVoice(vc):
vc_conf = loadJson(vc_file)
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)
@ -226,13 +225,11 @@ 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)
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)
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
@ -260,14 +257,13 @@ 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)
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)
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):
@ -283,12 +279,11 @@ 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)
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)
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

View File

@ -2,12 +2,12 @@ import os
import sys
import json
import shutil
import requests # type: ignore
import requests
import threading
try:
import discord # type: ignore
from discord import ApplicationContext, Option, Intents # type: ignore
from discord import ApplicationContext, Option, Intents # type: ignore
except Exception as exp:
print(f"Module py-cord is not installed. Make sure to run 'pip install -r requirements.txt' before first start")
sys.exit()
@ -83,8 +83,7 @@ async def on_voice_state_update(member, before, after):
await removeUserVoice(vc_from)
return
else:
if loadJson("config.json")["enable_nomic"]:
await changeNomicPerms("deny", vc_from, member)
await changeNomicPerms("deny", vc_from, member)
# If user joined vc
else:
@ -92,11 +91,9 @@ async def on_voice_state_update(member, before, after):
if isVoiceOfUser(vc_from, member):
await removeUserVoice(vc_from)
else:
if loadJson("config.json")["enable_nomic"]:
await changeNomicPerms("deny", vc_from, member)
await changeNomicPerms("deny", vc_from, member)
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 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)