Skip to content

Commit

Permalink
Merge pull request #266 from sarzz2/issue256
Browse files Browse the repository at this point in the history
updating error webhook
  • Loading branch information
SylteA authored Nov 14, 2023
2 parents 0aafec4 + 84eece2 commit 8f6f989
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bot/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import json
import logging
import os
import traceback
Expand Down Expand Up @@ -113,8 +114,12 @@ async def on_app_command_error(self, interaction: "InteractionType", error: app_

async def publish_error(self, interaction: "InteractionType", error: app_commands.AppCommandError) -> None:
"""Publishes the error to our error webhook."""
content = "\n".join(traceback.format_exception(type(error), error, error.__traceback__))
header = f"Ignored exception in command **{interaction.command.qualified_name}**"
content = "".join(traceback.format_exception(type(error), error, error.__traceback__))
header = (
f"Ignored exception in command **{interaction.command.qualified_name}** Invoked by **{interaction.user}**"
f"in channel **{interaction.channel.name}**"
)
invoked_details_document = await paste.create(str(json.dumps(interaction.data, indent=2)))

def wrap(code: str) -> str:
code = code.replace("`", "\u200b`")
Expand All @@ -129,6 +134,7 @@ def wrap(code: str) -> str:
embed = discord.Embed(
title=header, description=content, color=discord.Color.red(), timestamp=discord.utils.utcnow()
)
embed.add_field(name="Command Details: ", value=invoked_details_document.url, inline=True)
await self.error_webhook.send(embed=embed)

@tasks.loop(hours=24)
Expand Down

0 comments on commit 8f6f989

Please sign in to comment.