Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions bot/exts/moderation/infraction/superstarify.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ async def on_member_join(self, member: Member) -> None:

await self.reapply_infraction(infraction, action)

@command(name="superstarify", aliases=("force_nick", "star"))
@command(name="superstarify", aliases=("force_nick", "star", "starify"))
async def superstarify(
self,
ctx: Context,
member: Member,
duration: Expiry,
*,
reason: str = None,
reason: str = '',
) -> None:
"""
Temporarily force a random superstar name (like Taylor Swift) to be the user's nickname.
Expand All @@ -128,16 +128,16 @@ async def superstarify(

Alternatively, an ISO 8601 timestamp can be provided for the duration.

An optional reason can be provided. If no reason is given, the original name will be shown
in a generated reason.
An optional reason can be provided, which would be added to a message stating their old nickname
and linking to the nickname policy.
Comment thread
HassanAbouelela marked this conversation as resolved.
"""
if await _utils.get_active_infraction(ctx, member, "superstar"):
return

# Post the infraction to the API
old_nick = member.display_name
reason = reason or f"old nick: {old_nick}"
infraction = await _utils.post_infraction(ctx, member, "superstar", reason, duration, active=True)
infraction_reason = f'Old nickname: {old_nick}. {reason}'
infraction = await _utils.post_infraction(ctx, member, "superstar", infraction_reason, duration, active=True)
id_ = infraction["id"]

forced_nick = self.get_nick(id_, member.id)
Expand All @@ -152,37 +152,38 @@ async def action() -> None:
old_nick = escape_markdown(old_nick)
forced_nick = escape_markdown(forced_nick)

superstar_reason = f"Your nickname didn't comply with our [nickname policy]({NICKNAME_POLICY_URL})."
nickname_info = textwrap.dedent(f"""
Old nickname: `{old_nick}`
New nickname: `{forced_nick}`
""").strip()

user_message = (
f"Your previous nickname, **{old_nick}**, "
f"was so bad that we have decided to change it. "
f"Your new nickname will be **{forced_nick}**.\n\n"
"{reason}"
f"You will be unable to change your nickname until **{expiry_str}**. "
Comment thread
HassanAbouelela marked this conversation as resolved.
"If you're confused by this, please read our "
f"[official nickname policy]({NICKNAME_POLICY_URL})."
).format
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit unconventional and odd, but it's quite smart.


successful = await self.apply_infraction(
ctx, infraction, member, action(),
user_reason=superstar_reason,
user_reason=user_message(reason=f'**Additional details:** {reason}\n\n' if reason else ''),
additional_info=nickname_info
)

# Send an embed with the infraction information to the invoking context if
# superstar was successful.
# Send an embed with to the invoking context if superstar was successful.
if successful:
log.trace(f"Sending superstar #{id_} embed.")
embed = Embed(
title="Congratulations!",
title="Superstarified!",
colour=constants.Colours.soft_orange,
description=(
f"Your previous nickname, **{old_nick}**, "
f"was so bad that we have decided to change it. "
f"Your new nickname will be **{forced_nick}**.\n\n"
f"You will be unable to change your nickname until **{expiry_str}**.\n\n"
"If you're confused by this, please read our "
f"[official nickname policy]({NICKNAME_POLICY_URL})."
)
description=user_message(reason='')
)
await ctx.send(embed=embed)

@command(name="unsuperstarify", aliases=("release_nick", "unstar"))
@command(name="unsuperstarify", aliases=("release_nick", "unstar", "unstarify"))
async def unsuperstarify(self, ctx: Context, member: Member) -> None:
"""Remove the superstarify infraction and allow the user to change their nickname."""
await self.pardon_infraction(ctx, "superstar", member)
Expand Down