Skip to content

Commit

Permalink
[anonreporter] allow DM reports
Browse files Browse the repository at this point in the history
  • Loading branch information
Dav-Git committed Sep 8, 2024
1 parent d23748f commit 049790c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions anonreporter/anonreporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,21 @@ async def global_channel(self, ctx, channel: discord.TextChannel):
)
)

@commands.guild_only()
@commands.command()
async def anonreport(self, ctx, *, text: Optional[str]):
async def anonreport(self, ctx, guild: Optional[discord.Guild], *, text: Optional[str]):
"""Report something anonymously (don't include text to report via DM)"""

def msgcheck(m):
return m.guild is None and m.author.id == ctx.author.id

if not guild:
if ctx.guild:
guild = ctx.guild
else:
await ctx.send(_("You need to specify a guild."))
return
if not text:
if channel := await self.config.guild(ctx.guild).channel():
if channel := await self.config.guild(guild).channel():
try:
await ctx.author.send(_("Send your report here. You have 120s."))
text = (
Expand All @@ -80,14 +85,14 @@ def msgcheck(m):
await self._send_not_configured_correctly_message(ctx.channel)
return
else:
if channel := await self.config.guild(ctx.guild).channel():
await ctx.message.delete(delay=15)
if channel := await self.config.guild(guild).channel():
await ctx.message.delete(delay=5)
else:
await self._send_not_configured_correctly_message(ctx.channel)
return

if 0 < len(text) < 1000:
await ctx.guild.get_channel(channel).send(
await guild.get_channel(channel).send(
_("**New anonymous report:**\n{report}").format(report=text)
)
await ctx.tick()
Expand Down

0 comments on commit 049790c

Please sign in to comment.