4 Commits
v2.0 ... v2.2

Author SHA1 Message Date
65a0e1097e Updated version to 2.2 2023-05-07 16:24:09 +02:00
3fe67e18b0 Channel will terminate when the last user quit 2023-05-07 16:23:16 +02:00
91eecb4b0b Fixed channels logic 2023-05-02 16:13:11 +02:00
740c6a1464 Updated version to 2.1 2023-05-02 16:10:32 +02:00
3 changed files with 38 additions and 25 deletions

View File

@@ -9,6 +9,7 @@ from discord import (
utils,
)
from discord.ext import commands
from discord.abc import GuildChannel
from functions import (
appendLog,
@@ -32,6 +33,11 @@ class CogChannel(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_guild_channel_delete(self, channel: GuildChannel):
if isUserVoice(channel):
await removeUserVoice(channel)
@Cog.listener()
async def on_voice_state_update(
self, member: Member, before: VoiceState, after: VoiceState
@@ -40,26 +46,19 @@ class CogChannel(commands.Cog):
vc_from = before.channel
vc_to = after.channel
category = member.guild.get_channel(guildConfGet(member.guild, "category"))
# If user left vc
if after.channel is None and before.channel.category == category and len(before.channel.members) == 0:
if before.channel is not None and len(before.channel.members) == 0:
if isUserVoice(vc_from):
if isVoiceOfUser(vc_from, member):
await removeUserVoice(vc_from)
return
else:
if not isVoiceOfUser(vc_from, member):
if loadJson("config.json")["enable_nomic"]:
await changeNomicPerms("deny", vc_from, member)
await removeUserVoice(vc_from)
# If user joined vc
if after.channel is not None and after.channel.id == guildConfGet(member.guild, "channel"):
if isUserVoice(vc_from):
if isVoiceOfUser(vc_from, member):
await removeUserVoice(vc_from)
else:
if loadJson("config.json")["enable_nomic"]:
await changeNomicPerms("deny", vc_from, member)
if after.channel is not None and after.channel.id == guildConfGet(
member.guild, "channel"
):
if isUserVoice(vc_to):
if loadJson("config.json")["enable_nomic"]:
await changeNomicPerms("allow", vc_to, member)

View File

@@ -253,31 +253,45 @@ async def removeUserVoice(vc: VoiceChannel) -> None:
nomic_channel = utils.get(vc.guild.channels, id=vc_conf["nomic"])
remove(vc_file)
await needed_channel.delete()
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:
if needed_channel is None:
appendLog(
f"Removed voice channel '{needed_channel}' of user with id {str(vc_conf['ownerid'])}",
guild=vc.guild,
)
else:
await needed_channel.delete()
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)}",
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"]:
if nomic_channel is None:
appendLog(
f"Removed nomic channel '{nomic_channel}' of channel with id {str(needed_channel.id)}",
guild=vc.guild,
)
else:
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

View File

@@ -12,7 +12,7 @@ from os import getpid
from functions import *
pid = getpid()
version = 2.0
version = 2.2
if (
loadJson("config.json")["owner"] == "SET-OWNER-ID"