From 7b83b7c67b0d00fce0c7c88b9b306e82ca2f5622 Mon Sep 17 00:00:00 2001 From: Eivind Teig Date: Sat, 12 Sep 2020 01:28:39 +0200 Subject: Make nomination reason optional. We want to make the nominate command more attractive for our members of staff. --- bot/cogs/watchchannels/talentpool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/cogs/watchchannels/talentpool.py b/bot/cogs/watchchannels/talentpool.py index 76d6fe9bd..6ba397308 100644 --- a/bot/cogs/watchchannels/talentpool.py +++ b/bot/cogs/watchchannels/talentpool.py @@ -1,7 +1,7 @@ import logging import textwrap from collections import ChainMap -from typing import Union +from typing import Union, Optional from discord import Color, Embed, Member, User from discord.ext.commands import Cog, Context, group @@ -65,7 +65,7 @@ class TalentPool(WatchChannel, Cog, name="Talentpool"): @nomination_group.command(name='watch', aliases=('w', 'add', 'a'), root_aliases=("nominate",)) @with_role(*STAFF_ROLES) - async def watch_command(self, ctx: Context, user: FetchedMember, *, reason: str) -> None: + async def watch_command(self, ctx: Context, user: FetchedMember, *, reason: Optional[str] = '') -> None: """ Relay messages sent by the given `user` to the `#talent-pool` channel. -- cgit v1.2.3 From d75e1bc101578d3ce318ab0614aa448053daba7d Mon Sep 17 00:00:00 2001 From: Eivind Teig Date: Sat, 12 Sep 2020 01:30:50 +0200 Subject: Only show reason if it exist. Reduce the footer to not include reason if it does not exist. --- bot/cogs/watchchannels/watchchannel.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bot/cogs/watchchannels/watchchannel.py b/bot/cogs/watchchannels/watchchannel.py index a58b604c0..eb6d6f992 100644 --- a/bot/cogs/watchchannels/watchchannel.py +++ b/bot/cogs/watchchannels/watchchannel.py @@ -285,7 +285,10 @@ class WatchChannel(metaclass=CogABCMeta): else: message_jump = f"in [#{msg.channel.name}]({msg.jump_url})" - footer = f"Added {time_delta} by {actor} | Reason: {reason}" + # Add reason to the footer if it exists. + footer = f"Added {time_delta} by {actor}" + if reason: + footer += f" | Reason: {reason}" embed = Embed(description=f"{msg.author.mention} {message_jump}") embed.set_footer(text=textwrap.shorten(footer, width=128, placeholder="...")) -- cgit v1.2.3 From 0e24d104ac47685df4dbec2e8262da4a8c6c61d9 Mon Sep 17 00:00:00 2001 From: Eivind Teig Date: Sat, 12 Sep 2020 01:31:17 +0200 Subject: Update user cache after nomination reason edit. --- bot/cogs/watchchannels/talentpool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/cogs/watchchannels/talentpool.py b/bot/cogs/watchchannels/talentpool.py index 6ba397308..7e3aed971 100644 --- a/bot/cogs/watchchannels/talentpool.py +++ b/bot/cogs/watchchannels/talentpool.py @@ -203,7 +203,7 @@ class TalentPool(WatchChannel, Cog, name="Talentpool"): f"{self.api_endpoint}/{nomination_id}", json={field: reason} ) - + await self.fetch_user_cache() # Update cache. await ctx.send(f":white_check_mark: Updated the {field} of the nomination!") @Cog.listener() -- cgit v1.2.3 From 057efd069a7fc060a82d3a88afcce157d33c6267 Mon Sep 17 00:00:00 2001 From: Eivind Teig Date: Sat, 12 Sep 2020 01:38:57 +0200 Subject: Fix import order to pass linting tests. --- bot/cogs/watchchannels/talentpool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/cogs/watchchannels/talentpool.py b/bot/cogs/watchchannels/talentpool.py index 7e3aed971..66de567f9 100644 --- a/bot/cogs/watchchannels/talentpool.py +++ b/bot/cogs/watchchannels/talentpool.py @@ -1,7 +1,7 @@ import logging import textwrap from collections import ChainMap -from typing import Union, Optional +from typing import Optional, Union from discord import Color, Embed, Member, User from discord.ext.commands import Cog, Context, group -- cgit v1.2.3 From de32c8780d1d812fd0d088438ca9680a6e02b1e3 Mon Sep 17 00:00:00 2001 From: xithrius Date: Sat, 2 Jan 2021 21:54:17 -0800 Subject: No nominaton reason blank replaced by italic None --- bot/exts/moderation/watchchannels/talentpool.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bot/exts/moderation/watchchannels/talentpool.py b/bot/exts/moderation/watchchannels/talentpool.py index 7004b559a..fdba6606d 100644 --- a/bot/exts/moderation/watchchannels/talentpool.py +++ b/bot/exts/moderation/watchchannels/talentpool.py @@ -246,6 +246,8 @@ class TalentPool(WatchChannel, Cog, name="Talentpool"): log.debug(active) log.debug(type(nomination_object["inserted_at"])) + reason = nomination_object["reason"] or "*None*" + start_date = time.format_infraction(nomination_object["inserted_at"]) if active: lines = textwrap.dedent( @@ -254,7 +256,7 @@ class TalentPool(WatchChannel, Cog, name="Talentpool"): Status: **Active** Date: {start_date} Actor: {actor.mention if actor else actor_id} - Reason: {nomination_object["reason"]} + Reason: {reason} Nomination ID: `{nomination_object["id"]}` =============== """ @@ -267,7 +269,7 @@ class TalentPool(WatchChannel, Cog, name="Talentpool"): Status: Inactive Date: {start_date} Actor: {actor.mention if actor else actor_id} - Reason: {nomination_object["reason"]} + Reason: {reason} End date: {end_date} Unwatch reason: {nomination_object["end_reason"]} -- cgit v1.2.3 From b336e9721e6fb77a66536176e33587b8f9e09111 Mon Sep 17 00:00:00 2001 From: Xithrius <15021300+Xithrius@users.noreply.github.com> Date: Sat, 2 Jan 2021 23:28:47 -0800 Subject: Set reason to default as an empty string. Co-authored-by: Dennis Pham --- bot/exts/moderation/watchchannels/_watchchannel.py | 5 +---- bot/exts/moderation/watchchannels/talentpool.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/bot/exts/moderation/watchchannels/_watchchannel.py b/bot/exts/moderation/watchchannels/_watchchannel.py index d1e976190..f9fc12dc3 100644 --- a/bot/exts/moderation/watchchannels/_watchchannel.py +++ b/bot/exts/moderation/watchchannels/_watchchannel.py @@ -285,10 +285,7 @@ class WatchChannel(metaclass=CogABCMeta): else: message_jump = f"in [#{msg.channel.name}]({msg.jump_url})" - # Add reason to the footer if it exists. - footer = f"Added {time_delta} by {actor}" - if reason: - footer += f" | Reason: {reason}" + footer = f"Added {time_delta} by {actor} | Reason: {reason}" embed = Embed(description=f"{msg.author.mention} {message_jump}") embed.set_footer(text=textwrap.shorten(footer, width=128, placeholder="...")) diff --git a/bot/exts/moderation/watchchannels/talentpool.py b/bot/exts/moderation/watchchannels/talentpool.py index fdba6606d..8dd46a951 100644 --- a/bot/exts/moderation/watchchannels/talentpool.py +++ b/bot/exts/moderation/watchchannels/talentpool.py @@ -64,7 +64,7 @@ class TalentPool(WatchChannel, Cog, name="Talentpool"): @nomination_group.command(name='watch', aliases=('w', 'add', 'a'), root_aliases=("nominate",)) @has_any_role(*STAFF_ROLES) - async def watch_command(self, ctx: Context, user: FetchedMember, *, reason: Optional[str] = '') -> None: + async def watch_command(self, ctx: Context, user: FetchedMember, *, reason: str = '') -> None: """ Relay messages sent by the given `user` to the `#talent-pool` channel. -- cgit v1.2.3 From 175738048d78d74d0ac46b3e9849634a93a21b4c Mon Sep 17 00:00:00 2001 From: Xithrius <15021300+Xithrius@users.noreply.github.com> Date: Sat, 2 Jan 2021 23:29:21 -0800 Subject: Removed unnecessary debugging logs. Co-authored-by: Dennis Pham --- bot/exts/moderation/watchchannels/talentpool.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/bot/exts/moderation/watchchannels/talentpool.py b/bot/exts/moderation/watchchannels/talentpool.py index 8dd46a951..311c46d3b 100644 --- a/bot/exts/moderation/watchchannels/talentpool.py +++ b/bot/exts/moderation/watchchannels/talentpool.py @@ -243,8 +243,6 @@ class TalentPool(WatchChannel, Cog, name="Talentpool"): actor = guild.get_member(actor_id) active = nomination_object["active"] - log.debug(active) - log.debug(type(nomination_object["inserted_at"])) reason = nomination_object["reason"] or "*None*" -- cgit v1.2.3 From e0fe8fd1ec73b83c934a350b189210294dbb7637 Mon Sep 17 00:00:00 2001 From: xithrius Date: Sat, 2 Jan 2021 23:31:57 -0800 Subject: Removed 'Optional' import. --- bot/exts/moderation/watchchannels/talentpool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/exts/moderation/watchchannels/talentpool.py b/bot/exts/moderation/watchchannels/talentpool.py index 311c46d3b..df2ce586e 100644 --- a/bot/exts/moderation/watchchannels/talentpool.py +++ b/bot/exts/moderation/watchchannels/talentpool.py @@ -1,7 +1,7 @@ import logging import textwrap from collections import ChainMap -from typing import Optional, Union +from typing import Union from discord import Color, Embed, Member, User from discord.ext.commands import Cog, Context, group, has_any_role -- cgit v1.2.3