Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions techsupport_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,7 @@ async def slash_command_log(self: Self, interaction: discord.Interaction) -> Non
context=LogContext(guild=interaction.guild, channel=interaction.channel),
channel=log_channel,
embed=embed,
console_only=interaction.command.extras.get("suppress_logs", False),
)

async def can_run(
Expand Down
44 changes: 32 additions & 12 deletions techsupport_bot/commands/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ async def setup(bot: bot.TechSupportBot) -> None:
description="The ID of the channel to send auto-protect alerts to",
default=None,
)
config.add(
key="anonymous",
datatype="bool",
title="If reports are anonymous",
description="Whether reports are anonymous",
default=False,
)
await bot.add_cog(Report(bot=bot, extension_name="report"))
bot.add_extension_config("report", config)

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

embed = discord.Embed(title="New Report", description=report_str)
embed.color = discord.Color.red()
embed.set_author(
name=interaction.user.name,
icon_url=interaction.user.avatar.url or interaction.user.default_avatar.url,
)

config = self.bot.guild_configs[str(interaction.guild.id)]

is_anonymous = config.extensions.report.anonymous.value

if is_anonymous:
embed.set_author(name="Anonymous")
else:
embed.set_author(
name=interaction.user.name,
icon_url=interaction.user.avatar.url
or interaction.user.default_avatar.url,
)
embed.add_field(
name="User info",
value=(
f"**Name:** {interaction.user.name} ({interaction.user.mention})\n"
f"**Joined:** <t:{int(interaction.user.joined_at.timestamp())}:R>\n"
f"**Created:** <t:{int(interaction.user.created_at.timestamp())}:R>\n"
),
)

embed.add_field(
name="User info",
name="** **",
value=(
f"**Name:** {interaction.user.name} ({interaction.user.mention})\n"
f"**Joined:** <t:{int(interaction.user.joined_at.timestamp())}:R>\n"
f"**Created:** <t:{int(interaction.user.created_at.timestamp())}:R>\n"
f"**Sent from:** {interaction.channel.mention} [Jump to context]"
f"(https://discord.com/channels/{interaction.guild.id}/{interaction.channel.id}/"
f"{discord.utils.time_snowflake(datetime.datetime.utcnow())})"
Expand Down Expand Up @@ -101,11 +122,10 @@ async def report_command(
),
)

embed.set_footer(text=f"Author ID: {interaction.user.id}")
if not is_anonymous:
embed.set_footer(text=f"Author ID: {interaction.user.id}")
embed.timestamp = datetime.datetime.utcnow()

config = self.bot.guild_configs[str(interaction.guild.id)]

try:
alert_channel = interaction.guild.get_channel(
int(config.extensions.report.alert_channel.value)
Expand Down
Loading