From 901415986cd7c1c96e95f8a52eaaeaab85d997d7 Mon Sep 17 00:00:00 2001 From: Shuri2060 <29679284+Shuri2060@users.noreply.github.com> Date: Sun, 29 Oct 2023 23:29:04 +0000 Subject: [PATCH 1/2] feat: add user channels to occupy multiple channels msg --- plugins/clopen.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/clopen.py b/plugins/clopen.py index f3260e7..34c6f49 100644 --- a/plugins/clopen.py +++ b/plugins/clopen.py @@ -63,8 +63,11 @@ def unsolved_embed(reason: str) -> Embed: bot.commands.conf.prefix + "solved") ).set_author(name="Unsolved", icon_url=ping_url) -def limit_embed() -> Embed: - return Embed(color=0xB37C42, description="Please don't occupy multiple help channels.") +def limit_embed(user_id: int = 0) -> Embed: + extra_str = "" + if user_id: + extra_str = "You occupy ".join(client.get_channel(id) for id in conf.channels if conf[id, "owner"] == user_id and conf[id, "state"] in ("used", "pending",)) + return Embed(color=0xB37C42, description="Please don't occupy multiple help channels." + extra_str) def prompt_message(mention: int) -> str: return format("{!m} Has your question been resolved?", mention) @@ -113,7 +116,6 @@ def __setitem__(self, k: Tuple[int, Literal["expiry"]], v: Optional[float]) -> N @task(name="Clopen scheduler task", exc_backoff_base=10) async def scheduler_task() -> None: await client.wait_until_ready() - if sum(conf[id, "state"] == "available" for id in conf.channels) < conf.min_avail: for id in conf.channels: if conf[id, "state"] == "hidden": @@ -247,7 +249,7 @@ async def enact_occupied(channel: TextChannel, owner: Union[User, Member], *, except discord.Forbidden: pass if reached_limit: - await channel.send(embed=limit_embed(), allowed_mentions=AllowedMentions.none()) + await channel.send(embed=limit_embed(owner.id), allowed_mentions=AllowedMentions.none()) async def keep_occupied(id: int, msg_author_id: int) -> None: logger.debug("Bumping {} by {}".format(id, msg_author_id)) From dc57bf9077d7dd8cc1ce9c6931a3ab6b43d05ea3 Mon Sep 17 00:00:00 2001 From: Shuri2060 <29679284+Shuri2060@users.noreply.github.com> Date: Mon, 30 Oct 2023 10:21:30 +0000 Subject: [PATCH 2/2] grammar: missing space in str --- plugins/clopen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/clopen.py b/plugins/clopen.py index 34c6f49..3f33342 100644 --- a/plugins/clopen.py +++ b/plugins/clopen.py @@ -66,7 +66,7 @@ def unsolved_embed(reason: str) -> Embed: def limit_embed(user_id: int = 0) -> Embed: extra_str = "" if user_id: - extra_str = "You occupy ".join(client.get_channel(id) for id in conf.channels if conf[id, "owner"] == user_id and conf[id, "state"] in ("used", "pending",)) + extra_str = " You occupy ".join(client.get_channel(id) for id in conf.channels if conf[id, "owner"] == user_id and conf[id, "state"] in ("used", "pending",)) return Embed(color=0xB37C42, description="Please don't occupy multiple help channels." + extra_str) def prompt_message(mention: int) -> str: