Skip to content

Commit 2c047db

Browse files
authored
Make reporting able to be anonymous (#1425)
1 parent d6e325d commit 2c047db

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

techsupport_bot/bot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,7 @@ async def slash_command_log(self: Self, interaction: discord.Interaction) -> Non
10221022
context=LogContext(guild=interaction.guild, channel=interaction.channel),
10231023
channel=log_channel,
10241024
embed=embed,
1025+
console_only=interaction.command.extras.get("suppress_logs", False),
10251026
)
10261027

10271028
async def can_run(

techsupport_bot/commands/report.py

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ async def setup(bot: bot.TechSupportBot) -> None:
2828
description="The ID of the channel to send auto-protect alerts to",
2929
default=None,
3030
)
31+
config.add(
32+
key="anonymous",
33+
datatype="bool",
34+
title="If reports are anonymous",
35+
description="Whether reports are anonymous",
36+
default=False,
37+
)
3138
await bot.add_cog(Report(bot=bot, extension_name="report"))
3239
bot.add_extension_config("report", config)
3340

@@ -38,7 +45,7 @@ class Report(cogs.BaseCog):
3845
@app_commands.command(
3946
name="report",
4047
description="Reports something to the moderators",
41-
extras={"module": "report"},
48+
extras={"module": "report", "suppress_logs": True},
4249
)
4350
async def report_command(
4451
self: Self, interaction: discord.Interaction, report_str: str
@@ -59,17 +66,31 @@ async def report_command(
5966

6067
embed = discord.Embed(title="New Report", description=report_str)
6168
embed.color = discord.Color.red()
62-
embed.set_author(
63-
name=interaction.user.name,
64-
icon_url=interaction.user.avatar.url or interaction.user.default_avatar.url,
65-
)
69+
70+
config = self.bot.guild_configs[str(interaction.guild.id)]
71+
72+
is_anonymous = config.extensions.report.anonymous.value
73+
74+
if is_anonymous:
75+
embed.set_author(name="Anonymous")
76+
else:
77+
embed.set_author(
78+
name=interaction.user.name,
79+
icon_url=interaction.user.avatar.url
80+
or interaction.user.default_avatar.url,
81+
)
82+
embed.add_field(
83+
name="User info",
84+
value=(
85+
f"**Name:** {interaction.user.name} ({interaction.user.mention})\n"
86+
f"**Joined:** <t:{int(interaction.user.joined_at.timestamp())}:R>\n"
87+
f"**Created:** <t:{int(interaction.user.created_at.timestamp())}:R>\n"
88+
),
89+
)
6690

6791
embed.add_field(
68-
name="User info",
92+
name="** **",
6993
value=(
70-
f"**Name:** {interaction.user.name} ({interaction.user.mention})\n"
71-
f"**Joined:** <t:{int(interaction.user.joined_at.timestamp())}:R>\n"
72-
f"**Created:** <t:{int(interaction.user.created_at.timestamp())}:R>\n"
7394
f"**Sent from:** {interaction.channel.mention} [Jump to context]"
7495
f"(https://discord.com/channels/{interaction.guild.id}/{interaction.channel.id}/"
7596
f"{discord.utils.time_snowflake(datetime.datetime.utcnow())})"
@@ -101,11 +122,10 @@ async def report_command(
101122
),
102123
)
103124

104-
embed.set_footer(text=f"Author ID: {interaction.user.id}")
125+
if not is_anonymous:
126+
embed.set_footer(text=f"Author ID: {interaction.user.id}")
105127
embed.timestamp = datetime.datetime.utcnow()
106128

107-
config = self.bot.guild_configs[str(interaction.guild.id)]
108-
109129
try:
110130
alert_channel = interaction.guild.get_channel(
111131
int(config.extensions.report.alert_channel.value)

0 commit comments

Comments
 (0)