This commit is contained in:
insert 2024-08-11 15:14:26 -04:00
parent 1d78fc94bc
commit 683e182e79
Signed by: insert
GPG key ID: A70775C389ACF105
4 changed files with 67 additions and 1 deletions

View file

@ -4,6 +4,8 @@ from nextcord import TextInputStyle
import random
import aiosqlite as sqlite3
import aiohttp
import traceback
import sys
from urllib.parse import urlparse
import os
@ -37,6 +39,18 @@ class TurnModal(nextcord.ui.Modal):
pass
await interaction.followup.send(f"<@{self.fristrun.id}> it is now your turn!\n{self.text.value}")
async def on_error(self, error: nextcord.DiscordException, interaction: nextcord.Interaction):
error = traceback.format_exc()
print(error, file=sys.stderr)
message = f"```py\n{error[-1800:]}\n```\n Contact the bot owner if the error persists"
try:
await interaction.send(message, ephemeral=True)
except:
try:
await interaction.followup.send(message, ephemeral=True)
except:
await interaction.response.send_message(message, ephemeral=True)
class GameView(nextcord.ui.View):
def __init__(self):
@ -79,6 +93,18 @@ class GameView(nextcord.ui.View):
await interaction.response.send_modal(TurnModal(message,turnping,False))
return
async def on_error(self, error: nextcord.DiscordException, item: nextcord.ui.Item, interaction: nextcord.Interaction):
error = traceback.format_exc()
print(error, file=sys.stderr)
message = f"```py\n{error[-1800:]}\n```\n Contact the bot owner if the error persists"
try:
await interaction.send(message, ephemeral=True)
except:
try:
await interaction.followup.send(message, ephemeral=True)
except:
await interaction.response.send_message(message, ephemeral=True)
class gameutils(commands.Cog):
def __init__(self, bot: commands.Bot):

View file

@ -26,6 +26,18 @@ class RoleView(nextcord.ui.View):
await interaction.response.send_message(f"Added <@&{role.id}> to you!", ephemeral=True, allowed_mentions=nextcord.AllowedMentions.none())
return
async def on_error(self, error: nextcord.DiscordException, item: nextcord.ui.Item, interaction: nextcord.Interaction):
error = traceback.format_exc()
print(error, file=sys.stderr)
message = f"```py\n{error[-1800:]}\n```\n Contact <@{self.bot.owner_id}> if the error persists"
try:
await interaction.send(message, ephemeral=True)
except:
try:
await interaction.followup.send(message, ephemeral=True)
except:
await interaction.response.send_message(message, ephemeral=True)
class rolebutton(commands.Cog):

View file

@ -55,6 +55,19 @@ class ApplicationView(nextcord.ui.View):
await interaction.response.edit_message(embed=embed, view=None)
return
async def on_error(self, error: nextcord.DiscordException, item: nextcord.ui.Item, interaction: nextcord.Interaction):
error = traceback.format_exc()
print(error, file=sys.stderr)
message = f"```py\n{error[-1800:]}\n```\n Contact <@{self.bot.owner_id}> if the error persists"
try:
await interaction.send(message, ephemeral=True)
except:
try:
await interaction.followup.send(message, ephemeral=True)
except:
await interaction.response.send_message(message, ephemeral=True)
class ApplicationModal(nextcord.ui.Modal):
def __init__(self,user,bot):
self.victim = user
@ -88,7 +101,7 @@ class ApplicationModal(nextcord.ui.Modal):
)
print(self.image.value)
if urlparse(self.image.value).netloc != 'media.discordapp.net' and urlparse(self.image.value).netloc != 'cdn.discordapp.com':
await interaction.send_message(f"for security reasons, the bot only accepts images from media.discordapp.net or cdn.discordapp.com", ephemeral=True)
await interaction.send(f"for security reasons, the bot only accepts images from media.discordapp.net or cdn.discordapp.com", ephemeral=True)
return
async with aiohttp.ClientSession() as session:
async with session.get(self.image.value) as response:

View file

@ -6,6 +6,8 @@ from random import randint
import aiosqlite as sqlite3
import requests
import json
import traceback
import sys
from datetime import datetime
import base64
from urllib.parse import urlparse
@ -75,6 +77,19 @@ class BlogModal(nextcord.ui.Modal):
responce = requests.post(self.endpoint, headers=header, json=post)
await interaction.response.send_message(f"<@666378959184855042> someone posted to the blog, you should probably approve it {responce.status_code}")
async def on_error(self, error: nextcord.DiscordException, interaction: nextcord.Interaction):
error = traceback.format_exc()
print(error, file=sys.stderr)
message = f"```py\n{error[-1800:]}\n```\n Contact the bot owner if the error persists"
try:
await interaction.send(message, ephemeral=True)
except:
try:
await interaction.followup.send(message, ephemeral=True)
except:
await interaction.response.send_message(message, ephemeral=True)
class wordpress(commands.Cog):
def __init__(self, bot: commands.Bot):