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
8 changes: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
exclude =
.git,
__pycache__,
.venv,
venv,
build,
dist
9 changes: 2 additions & 7 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,8 @@ async def _safe_ctx_send(message: str) -> None:

async def on_app_command_error(self, interaction: discord.Interaction, error: app_commands.AppCommandError):
"""Handle slash command errors."""
# Silence unknown slash/app commands
# app_commands doesn't expose a simple CommandNotFound class in some versions, so be conservative
try:
from discord import app_commands as _appc
# In later versions, AppCommandError subclasses may exist; ignore generic NotFound-like errors
except Exception:
_appc = None
# Silence unknown slash/app commands.
# `app_commands` doesn't expose a stable CommandNotFound across versions, so be conservative.

# If it's a cooldown, inform user
if isinstance(error, app_commands.CommandOnCooldown):
Expand Down
1 change: 0 additions & 1 deletion cogs/afk.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ async def set_afk_command(self, ctx: commands.Context, *, reason: Optional[str]
# Check if user is already AFK
was_afk = self.is_afk(ctx.author.id)
if was_afk:
old_info = self.get_afk_info(ctx.author.id)
action_text = "updated"
else:
action_text = "set"
Expand Down
4 changes: 0 additions & 4 deletions cogs/codebuddy_leaderboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ async def before_weekly_reset(self):
@app_commands.command(name="codeweek", description="Show the weekly coding leaderboard")
async def codeweek(self, interaction: discord.Interaction):
"""Display the weekly leaderboard."""
start_time = datetime.datetime.now()
try:
# Immediate simple response first
embed = discord.Embed(
Expand Down Expand Up @@ -126,7 +125,6 @@ async def codeweek(self, interaction: discord.Interaction):
@commands.command(name="codeweek", aliases=["cw", "cwlb"])
async def codeweek_prefix(self, ctx):
"""Display the weekly leaderboard."""
start_time = datetime.datetime.now()
try:
# Immediate simple response first
embed = discord.Embed(
Expand Down Expand Up @@ -202,7 +200,6 @@ async def codeweek_prefix(self, ctx):
@app_commands.command(name="codestreak", description="Show the coding streak leaderboard")
async def codestreak(self, interaction: discord.Interaction):
"""Display the streak leaderboard."""
start_time = datetime.datetime.now()
try:
# Immediate simple response first
embed = discord.Embed(
Expand Down Expand Up @@ -307,7 +304,6 @@ async def codestreak(self, interaction: discord.Interaction):
@commands.command(name="codestreak", aliases=["cs", "cslb"])
async def codestreak_prefix(self, ctx):
"""Display the streak leaderboard."""
start_time = datetime.datetime.now()
try:
# Immediate simple response first
embed = discord.Embed(
Expand Down
8 changes: 3 additions & 5 deletions cogs/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ def __init__(self, bot: commands.Bot):
)
]

# Track if we've added the Quiz category
quiz_added = False
quiz_command_count = 0

# Cogs to merge into Misc (kept lightweight)
Expand Down Expand Up @@ -292,7 +290,7 @@ def _create_category_embed(self, cog_name: str) -> discord.Embed:
else:
embed.description = "No commands available in this category."

embed.set_footer(text=f"Use ?helpmenu <command> for detailed help")
embed.set_footer(text="Use ?helpmenu <command> for detailed help")
return embed

# Handle special Misc category that combines multiple cogs
Expand Down Expand Up @@ -365,7 +363,7 @@ def _create_category_embed(self, cog_name: str) -> discord.Embed:
else:
embed.description = "No commands available in this category."

embed.set_footer(text=f"Use ?helpmenu <command> for detailed help")
embed.set_footer(text="Use ?helpmenu <command> for detailed help")
return embed

# Find the cog (case-insensitive)
Expand Down Expand Up @@ -452,7 +450,7 @@ def _create_category_embed(self, cog_name: str) -> discord.Embed:
else:
embed.description = "No commands available in this category."

embed.set_footer(text=f"Use ?helpmenu <command> for detailed help")
embed.set_footer(text="Use ?helpmenu <command> for detailed help")
return embed


Expand Down
4 changes: 1 addition & 3 deletions cogs/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,7 @@ async def bug_report(self, ctx: commands.Context, *, bug: str):
"""Report a bug to the support server."""
# Support server channel ID
SUPPORT_CHANNEL_ID = 1452739906525728828

# Get interaction for hybrid command
interaction = ctx.interaction or ctx

user = ctx.author
guild = ctx.guild

Expand Down
2 changes: 1 addition & 1 deletion cogs/rockpaperscissors.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def format_message(self, cancelled=False):
winner = self.game.players[winner_id]
body = f"\n{winner.mention} has **won!**\n\n"
else:
body = f"Draw!\n\n"
body = "Draw!\n\n"
body += f"{self.format_player_line_endgame(0)}\n{self.format_player_line_endgame(1)}"
if rounds:
body += f"\n\n{rounds}"
Expand Down
4 changes: 0 additions & 4 deletions cogs/staff_applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,6 @@ async def on_interaction(self, interaction: discord.Interaction):
# But to make it work, I need to respond.
# If the view was attached via `add_view`, it handles it. If not, this global listener does.

parts = custom_id.split(':')
action = parts[1]
user_id = int(parts[2])

# We need to recreate the modal logic here manually since the View instance is lost
# But `send_modal` needs a Modal instance.
# Checking if the interaction was already handled (if View was attached)?
Expand Down
11 changes: 6 additions & 5 deletions cogs/starboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ async def starboard_setup(self, ctx: commands.Context, channel: discord.TextChan

embed = create_success_embed(
" Starboard Setup Complete!",
f"Your modern starboard system is now active and ready to showcase your community's best messages!"
"Your modern starboard system is now active and ready to showcase your community's best messages!"
)
embed.color = 0x00FF7F # Spring green
embed.add_field(name=" Channel", value=channel.mention, inline=True)
Expand Down Expand Up @@ -465,7 +465,7 @@ async def starboard_stats(self, ctx: commands.Context):

embed = discord.Embed(
title="⭐ Starboard Statistics",
description=f"Here's how your server is shining!",
description="Here's how your server is shining!",
color=color
)

Expand Down Expand Up @@ -916,7 +916,7 @@ async def update_starboard_message(self, message: discord.Message, star_count: i
async with aiosqlite.connect(self.database_path) as db:
await db.execute("DELETE FROM starred_messages WHERE starboard_message_id = ?", (starboard_msg_id,))
await db.commit()
except Exception as e:
except Exception:
self.logger.exception(f"Error updating starboard message {starboard_msg_id} for original {message.id}")

async def remove_starboard_message(self, starboard_msg_id: int, settings: Dict):
Expand All @@ -930,7 +930,7 @@ async def remove_starboard_message(self, starboard_msg_id: int, settings: Dict):
await starboard_msg.delete()
except discord.NotFound:
pass # Already deleted
except Exception as e:
except Exception:
self.logger.exception(f"Error removing starboard message {starboard_msg_id}")

async def create_starboard_embed(self, message: discord.Message, star_count: int, settings: Dict) -> discord.Embed:
Expand All @@ -952,7 +952,8 @@ async def create_starboard_embed(self, message: discord.Message, star_count: int
content = content[:1500] + "..."

# Highlight the message by using a block quote style in the description
description = f"> {content.replace('\n', '\n> ')}"
quoted_content = content.replace("\n", "\n> ")
description = f"> {quoted_content}"

embed = discord.Embed(
description=description,
Expand Down
32 changes: 16 additions & 16 deletions cogs/tickets.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ async def _restore_persistent_views(self):

# Fetch the message to ensure it exists
try:
message = await channel.fetch_message(message_id)
await channel.fetch_message(message_id)
# Create and attach the persistent view
view = TicketPanelView(self)
# The view is automatically registered due to persistent custom_id
Expand Down Expand Up @@ -1090,9 +1090,9 @@ async def ticket_log_setup(self, ctx, channel: Optional[discord.TextChannel] = N
embed.add_field(
name="ℹ️ Information",
value="Ticket actions (create, close, claim) will be logged to this channel.\n\n"
f"• **Change it:** `/ticketlog #new-channel`\n"
f"• **Disable custom:** `/ticketlog-disable`\n"
f"• **Quick disable:** Rename this channel",
"• **Change it:** `/ticketlog #new-channel`\n"
"• **Disable custom:** `/ticketlog-disable`\n"
"• **Quick disable:** Rename this channel",
inline=False
)
else:
Expand Down Expand Up @@ -1265,10 +1265,10 @@ async def ticket_support_role(self, ctx, role: Optional[discord.Role] = None):
)
embed.add_field(
name="ℹ️ Information",
value=f"This role will be pinged when new tickets are created.\n\n"
f"• **Change it:** `/ticketsupport @new-role`\n"
f"• **Remove it:** `/ticketsupport-disable`\n"
f"• **Set via panel:** `/ticketpanel #channel @role`",
value="This role will be pinged when new tickets are created.\n\n"
"• **Change it:** `/ticketsupport @new-role`\n"
"• **Remove it:** `/ticketsupport-disable`\n"
"• **Set via panel:** `/ticketpanel #channel @role`",
inline=False
)
else:
Expand Down Expand Up @@ -1670,10 +1670,10 @@ async def ticket_report_role(self, ctx, role: Optional[discord.Role] = None):
)
embed.add_field(
name="ℹ️ Information",
value=f"This role will be pinged when report tickets are created.\n\n"
f"• **Change it:** `/ticketreport @new-role`\n"
f"• **Remove it:** `/ticketreport-disable`\n"
f"• **Set via panel:** `/ticketpanel report_role:@role`",
value="This role will be pinged when report tickets are created.\n\n"
"• **Change it:** `/ticketreport @new-role`\n"
"• **Remove it:** `/ticketreport-disable`\n"
"• **Set via panel:** `/ticketpanel report_role:@role`",
inline=False
)
else:
Expand Down Expand Up @@ -1809,10 +1809,10 @@ async def ticket_partner_role(self, ctx, role: Optional[discord.Role] = None):
)
embed.add_field(
name="ℹ️ Information",
value=f"This role will be pinged when partnership tickets are created.\n\n"
f"• **Change it:** `/ticketpartner @new-role`\n"
f"• **Remove it:** `/ticketpartner-disable`\n"
f"• **Set via panel:** `/ticketpanel partner_role:@role`",
value="This role will be pinged when partnership tickets are created.\n\n"
"• **Change it:** `/ticketpartner @new-role`\n"
"• **Remove it:** `/ticketpartner-disable`\n"
"• **Set via panel:** `/ticketpanel partner_role:@role`",
inline=False
)
else:
Expand Down
4 changes: 0 additions & 4 deletions utils/codebuddy_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,6 @@ async def increment_quest_quiz_count(user_id: int):
Increment the quiz count for today's quest.
Returns True if quest was completed with this quiz.
"""
today = datetime.date.today()

async with aiosqlite.connect(DB_PATH) as db:
# Get current progress
progress = await get_daily_quest_progress(user_id)
Expand Down Expand Up @@ -481,8 +479,6 @@ async def mark_quest_voted(user_id: int):
Mark that the user has voted today.
Returns True if quest was completed with this vote.
"""
today = datetime.date.today()

async with aiosqlite.connect(DB_PATH) as db:
# Get current progress
progress = await get_daily_quest_progress(user_id)
Expand Down
4 changes: 3 additions & 1 deletion utils/codingquestions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

def get_random_question():
"""Returns a non repeating randomized question"""
global _index, _question_pool
global _index

if _index >= len(_question_pool):
random.shuffle(_question_pool)
Expand All @@ -28,6 +28,8 @@ def get_random_question():
_index += 1
return fix_question(q)



def fix_question(question):
"""Randomizes options while keeping the correct answer accurate."""
# Extract answer text.
Expand Down
Loading