Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,3 @@ python-dotenv
pytest
nudenet>=3.4.2
rapidocr-onnxruntime>=1.4.4
Pillow
opencv-python-headless
aiohttp
SpeechRecognition
imageio-ffmpeg
28 changes: 28 additions & 0 deletions src/cogs/logs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import nextcord
from nextcord.ext import commands
from nextcord.ext.application_checks import (
ApplicationCheckFailure,
ApplicationMissingAnyRole,
ApplicationMissingPermissions,
ApplicationMissingRole,
)
import traceback
import sys
import json
Expand All @@ -15,6 +21,13 @@
# Avoid multiple logging instances
already_redirected = False

IGNORED_APPLICATION_ERRORS = (
ApplicationCheckFailure,
ApplicationMissingAnyRole,
ApplicationMissingPermissions,
ApplicationMissingRole,
)


class StreamToDiscord(io.StringIO):
def __init__(self, bot: commands.Bot, channel_id: int, stream_name: str):
Expand Down Expand Up @@ -121,6 +134,21 @@ async def on_command_error(self, ctx: commands.Context, error: Exception):

@commands.Cog.listener()
async def on_application_command_error(self, interaction: nextcord.Interaction, error: Exception):
original_error = getattr(error, "original", error)
if isinstance(original_error, IGNORED_APPLICATION_ERRORS):
try:
await interaction.response.send_message(
"You do not have permission to use this command.", ephemeral=True
)
except nextcord.errors.InteractionResponded:
try:
await interaction.followup.send(
"You do not have permission to use this command.", ephemeral=True
)
except Exception:
pass
return

error_msg = "".join(traceback.format_exception(type(error), error, error.__traceback__))

try:
Expand Down
7 changes: 4 additions & 3 deletions src/cogs/moderation/appeal.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
config_path = "config.json"
conf = Config(config_path)

APPEAL_GUILD_ID = int(conf.get("ban_appeal_server"))
ban_appeal_server = conf.get("ban_appeal_server")
APPEAL_GUILD_IDS = [int(ban_appeal_server)] if ban_appeal_server is not None else []

REVIEW_DELAY_SECONDS = 60 * 60 * 24 * 14 # 2 weeks
REAPPEAL_DELAY_SECONDS = 60 * 60 * 24 * 84 # 12 weeks
Expand Down Expand Up @@ -302,7 +303,7 @@ async def create_views(self):
@slash_command(
name="appealbutton",
default_member_permissions=0x8,
guild_ids=[APPEAL_GUILD_ID],
guild_ids=APPEAL_GUILD_IDS,
)
async def send_appeal_button(self, inter: Interaction):
await inter.send(
Expand All @@ -323,4 +324,4 @@ async def send_appeal_button(self, inter: Interaction):


def setup(bot: APBot) -> None:
bot.add_cog(BanAppeal(bot))
bot.add_cog(BanAppeal(bot))
Loading
Loading