mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[V3 Report] Patch issue with attachment grabbing (#1822)
* This fixes the issue on report's side * This prevents delete_delay from causing future issues where message objects are needed * black format pass * use the tools we have to clean this logic up a lot
This commit is contained in:
parent
d5f5ddbec5
commit
49b80e9fe3
@ -1440,7 +1440,13 @@ class Mod:
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def on_command(self, ctx: commands.Context):
|
async def on_command_completion(self, ctx: commands.Context):
|
||||||
|
await self._delete_delay(ctx)
|
||||||
|
|
||||||
|
async def on_command_error(self, ctx: commands.Context, error):
|
||||||
|
await self._delete_delay(ctx)
|
||||||
|
|
||||||
|
async def _delete_delay(self, ctx: commands.Context):
|
||||||
"""Currently used for:
|
"""Currently used for:
|
||||||
* delete delay"""
|
* delete delay"""
|
||||||
guild = ctx.guild
|
guild = ctx.guild
|
||||||
|
|||||||
@ -212,11 +212,6 @@ class Reports:
|
|||||||
guild = await self.discover_guild(
|
guild = await self.discover_guild(
|
||||||
author, prompt=_("Select a server to make a report in by number.")
|
author, prompt=_("Select a server to make a report in by number.")
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
try:
|
|
||||||
await ctx.message.delete()
|
|
||||||
except discord.Forbidden:
|
|
||||||
pass
|
|
||||||
if guild is None:
|
if guild is None:
|
||||||
return
|
return
|
||||||
g_active = await self.config.guild(guild).active()
|
g_active = await self.config.guild(guild).active()
|
||||||
@ -234,17 +229,10 @@ class Reports:
|
|||||||
"later."
|
"later."
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if author.id in self.user_cache:
|
if author.id in self.user_cache:
|
||||||
return await author.send(
|
return await author.send(
|
||||||
_("Please finish making your prior report before making an additional one")
|
_("Please finish making your prior report before making an additional one")
|
||||||
)
|
)
|
||||||
|
|
||||||
if ctx.guild:
|
|
||||||
try:
|
|
||||||
await ctx.message.delete()
|
|
||||||
except (discord.Forbidden, discord.HTTPException):
|
|
||||||
pass
|
|
||||||
self.user_cache.append(author.id)
|
self.user_cache.append(author.id)
|
||||||
|
|
||||||
if _report:
|
if _report:
|
||||||
@ -261,9 +249,7 @@ class Reports:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
except discord.Forbidden:
|
except discord.Forbidden:
|
||||||
await ctx.send(_("This requires DMs enabled."))
|
return await ctx.send(_("This requires DMs enabled."))
|
||||||
self.user_cache.remove(author.id)
|
|
||||||
return
|
|
||||||
|
|
||||||
def pred(m):
|
def pred(m):
|
||||||
return m.author == author and m.channel == dm.channel
|
return m.author == author and m.channel == dm.channel
|
||||||
@ -271,7 +257,7 @@ class Reports:
|
|||||||
try:
|
try:
|
||||||
message = await self.bot.wait_for("message", check=pred, timeout=180)
|
message = await self.bot.wait_for("message", check=pred, timeout=180)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
await author.send(_("You took too long. Try again later."))
|
return await author.send(_("You took too long. Try again later."))
|
||||||
else:
|
else:
|
||||||
val = await self.send_report(message, guild)
|
val = await self.send_report(message, guild)
|
||||||
|
|
||||||
@ -282,7 +268,19 @@ class Reports:
|
|||||||
await author.send(_("Your report was submitted. (Ticket #{})").format(val))
|
await author.send(_("Your report was submitted. (Ticket #{})").format(val))
|
||||||
self.antispam[guild.id][author.id].stamp()
|
self.antispam[guild.id][author.id].stamp()
|
||||||
|
|
||||||
self.user_cache.remove(author.id)
|
@report.after_invoke
|
||||||
|
async def report_cleanup(self, ctx: commands.Context):
|
||||||
|
"""
|
||||||
|
The logic is cleaner this way
|
||||||
|
"""
|
||||||
|
if ctx.author.id in self.user_cache:
|
||||||
|
self.user_cache.remove(ctx.author.id)
|
||||||
|
if ctx.guild and ctx.invoked_subcommand is None:
|
||||||
|
if ctx.channel.permissions_for(ctx.guild.me).manage_messages:
|
||||||
|
try:
|
||||||
|
await ctx.message.delete()
|
||||||
|
except discord.NotFound:
|
||||||
|
pass
|
||||||
|
|
||||||
async def on_raw_reaction_add(self, payload):
|
async def on_raw_reaction_add(self, payload):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user