From 4f7d7b85b648f9ff12703c25852d11a72dcb73eb Mon Sep 17 00:00:00 2001 From: insert Date: Sun, 11 Aug 2024 13:02:24 -0400 Subject: [PATCH] Update --- misc.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 misc.py diff --git a/misc.py b/misc.py new file mode 100644 index 0000000..24b636a --- /dev/null +++ b/misc.py @@ -0,0 +1,39 @@ +import nextcord +from nextcord.ext import commands, application_checks +from nextcord import TextInputStyle +import traceback +import random +import aiosqlite as sqlite3 +import aiohttp +from urllib.parse import urlparse +import os +import sys + +errormsg = ["How could you do this to me!", "I tried my best...", "There's always next time", "Simply processed too hard", "Perhaps this will be fixed", "You found an easter egg! Wait no it's just an error..."] + + +class misc(commands.Cog): + + def __init__(self, bot: commands.Bot): + self.bot = bot + + @commands.Cog.listener('on_application_command_error') + async def errorhandler(self, interaction: nextcord.Interaction, error: nextcord.DiscordException): + error = traceback.format_exception(type(error), error, error.__traceback__) + print(error, file=sys.stderr) + random.shuffle(errormsg) + message = f"{errormsg[0]}\n```py\n{error[-1800:]}\n```\n Contact <@{self.bot.owner_id}> if the error persists" + try: + await interaction.response.send_message(message, ephemeral=True) + except: + await interaction.followup.send(message, ephemeral=True) + + @nextcord.slash_command( + name="error", + description="DEBUG: throw an error", + guild_ids=[699285282276507708], + ) + async def thrower(self, interaction: nextcord.Interaction): + errorlist = [1,2] + await interaction.response.send_message(errorlist[4]) +