Skip to content

Commit d516f14

Browse files
authored
Merge pull request #23 from TheCodeVerseHub/yc45
Fix starboard embed SyntaxError and tighten flake8 linting
2 parents 12bc5b2 + cbd18eb commit d516f14

12 files changed

Lines changed: 40 additions & 51 deletions

.flake8

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[flake8]
2+
exclude =
3+
.git,
4+
__pycache__,
5+
.venv,
6+
venv,
7+
build,
8+
dist

bot.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,8 @@ async def _safe_ctx_send(message: str) -> None:
212212

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

223218
# If it's a cooldown, inform user
224219
if isinstance(error, app_commands.CommandOnCooldown):

cogs/afk.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ async def set_afk_command(self, ctx: commands.Context, *, reason: Optional[str]
168168
# Check if user is already AFK
169169
was_afk = self.is_afk(ctx.author.id)
170170
if was_afk:
171-
old_info = self.get_afk_info(ctx.author.id)
172171
action_text = "updated"
173172
else:
174173
action_text = "set"

cogs/codebuddy_leaderboard.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ async def before_weekly_reset(self):
2828
@app_commands.command(name="codeweek", description="Show the weekly coding leaderboard")
2929
async def codeweek(self, interaction: discord.Interaction):
3030
"""Display the weekly leaderboard."""
31-
start_time = datetime.datetime.now()
3231
try:
3332
# Immediate simple response first
3433
embed = discord.Embed(
@@ -126,7 +125,6 @@ async def codeweek(self, interaction: discord.Interaction):
126125
@commands.command(name="codeweek", aliases=["cw", "cwlb"])
127126
async def codeweek_prefix(self, ctx):
128127
"""Display the weekly leaderboard."""
129-
start_time = datetime.datetime.now()
130128
try:
131129
# Immediate simple response first
132130
embed = discord.Embed(
@@ -202,7 +200,6 @@ async def codeweek_prefix(self, ctx):
202200
@app_commands.command(name="codestreak", description="Show the coding streak leaderboard")
203201
async def codestreak(self, interaction: discord.Interaction):
204202
"""Display the streak leaderboard."""
205-
start_time = datetime.datetime.now()
206203
try:
207204
# Immediate simple response first
208205
embed = discord.Embed(
@@ -307,7 +304,6 @@ async def codestreak(self, interaction: discord.Interaction):
307304
@commands.command(name="codestreak", aliases=["cs", "cslb"])
308305
async def codestreak_prefix(self, ctx):
309306
"""Display the streak leaderboard."""
310-
start_time = datetime.datetime.now()
311307
try:
312308
# Immediate simple response first
313309
embed = discord.Embed(

cogs/help.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ def __init__(self, bot: commands.Bot):
8585
)
8686
]
8787

88-
# Track if we've added the Quiz category
89-
quiz_added = False
9088
quiz_command_count = 0
9189

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

295-
embed.set_footer(text=f"Use ?helpmenu <command> for detailed help")
293+
embed.set_footer(text="Use ?helpmenu <command> for detailed help")
296294
return embed
297295

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

368-
embed.set_footer(text=f"Use ?helpmenu <command> for detailed help")
366+
embed.set_footer(text="Use ?helpmenu <command> for detailed help")
369367
return embed
370368

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

455-
embed.set_footer(text=f"Use ?helpmenu <command> for detailed help")
453+
embed.set_footer(text="Use ?helpmenu <command> for detailed help")
456454
return embed
457455

458456

cogs/misc.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,7 @@ async def bug_report(self, ctx: commands.Context, *, bug: str):
351351
"""Report a bug to the support server."""
352352
# Support server channel ID
353353
SUPPORT_CHANNEL_ID = 1452739906525728828
354-
355-
# Get interaction for hybrid command
356-
interaction = ctx.interaction or ctx
354+
357355
user = ctx.author
358356
guild = ctx.guild
359357

cogs/rockpaperscissors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def format_message(self, cancelled=False):
192192
winner = self.game.players[winner_id]
193193
body = f"\n{winner.mention} has **won!**\n\n"
194194
else:
195-
body = f"Draw!\n\n"
195+
body = "Draw!\n\n"
196196
body += f"{self.format_player_line_endgame(0)}\n{self.format_player_line_endgame(1)}"
197197
if rounds:
198198
body += f"\n\n{rounds}"

cogs/staff_applications.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,6 @@ async def on_interaction(self, interaction: discord.Interaction):
487487
# But to make it work, I need to respond.
488488
# If the view was attached via `add_view`, it handles it. If not, this global listener does.
489489

490-
parts = custom_id.split(':')
491-
action = parts[1]
492-
user_id = int(parts[2])
493-
494490
# We need to recreate the modal logic here manually since the View instance is lost
495491
# But `send_modal` needs a Modal instance.
496492
# Checking if the interaction was already handled (if View was attached)?

cogs/starboard.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ async def starboard_setup(self, ctx: commands.Context, channel: discord.TextChan
284284

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

466466
embed = discord.Embed(
467467
title="⭐ Starboard Statistics",
468-
description=f"Here's how your server is shining!",
468+
description="Here's how your server is shining!",
469469
color=color
470470
)
471471

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

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

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

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

957958
embed = discord.Embed(
958959
description=description,

cogs/tickets.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ async def _restore_persistent_views(self):
180180

181181
# Fetch the message to ensure it exists
182182
try:
183-
message = await channel.fetch_message(message_id)
183+
await channel.fetch_message(message_id)
184184
# Create and attach the persistent view
185185
view = TicketPanelView(self)
186186
# The view is automatically registered due to persistent custom_id
@@ -1090,9 +1090,9 @@ async def ticket_log_setup(self, ctx, channel: Optional[discord.TextChannel] = N
10901090
embed.add_field(
10911091
name="ℹ️ Information",
10921092
value="Ticket actions (create, close, claim) will be logged to this channel.\n\n"
1093-
f"• **Change it:** `/ticketlog #new-channel`\n"
1094-
f"• **Disable custom:** `/ticketlog-disable`\n"
1095-
f"• **Quick disable:** Rename this channel",
1093+
"• **Change it:** `/ticketlog #new-channel`\n"
1094+
"• **Disable custom:** `/ticketlog-disable`\n"
1095+
"• **Quick disable:** Rename this channel",
10961096
inline=False
10971097
)
10981098
else:
@@ -1265,10 +1265,10 @@ async def ticket_support_role(self, ctx, role: Optional[discord.Role] = None):
12651265
)
12661266
embed.add_field(
12671267
name="ℹ️ Information",
1268-
value=f"This role will be pinged when new tickets are created.\n\n"
1269-
f"• **Change it:** `/ticketsupport @new-role`\n"
1270-
f"• **Remove it:** `/ticketsupport-disable`\n"
1271-
f"• **Set via panel:** `/ticketpanel #channel @role`",
1268+
value="This role will be pinged when new tickets are created.\n\n"
1269+
"• **Change it:** `/ticketsupport @new-role`\n"
1270+
"• **Remove it:** `/ticketsupport-disable`\n"
1271+
"• **Set via panel:** `/ticketpanel #channel @role`",
12721272
inline=False
12731273
)
12741274
else:
@@ -1670,10 +1670,10 @@ async def ticket_report_role(self, ctx, role: Optional[discord.Role] = None):
16701670
)
16711671
embed.add_field(
16721672
name="ℹ️ Information",
1673-
value=f"This role will be pinged when report tickets are created.\n\n"
1674-
f"• **Change it:** `/ticketreport @new-role`\n"
1675-
f"• **Remove it:** `/ticketreport-disable`\n"
1676-
f"• **Set via panel:** `/ticketpanel report_role:@role`",
1673+
value="This role will be pinged when report tickets are created.\n\n"
1674+
"• **Change it:** `/ticketreport @new-role`\n"
1675+
"• **Remove it:** `/ticketreport-disable`\n"
1676+
"• **Set via panel:** `/ticketpanel report_role:@role`",
16771677
inline=False
16781678
)
16791679
else:
@@ -1809,10 +1809,10 @@ async def ticket_partner_role(self, ctx, role: Optional[discord.Role] = None):
18091809
)
18101810
embed.add_field(
18111811
name="ℹ️ Information",
1812-
value=f"This role will be pinged when partnership tickets are created.\n\n"
1813-
f"• **Change it:** `/ticketpartner @new-role`\n"
1814-
f"• **Remove it:** `/ticketpartner-disable`\n"
1815-
f"• **Set via panel:** `/ticketpanel partner_role:@role`",
1812+
value="This role will be pinged when partnership tickets are created.\n\n"
1813+
"• **Change it:** `/ticketpartner @new-role`\n"
1814+
"• **Remove it:** `/ticketpartner-disable`\n"
1815+
"• **Set via panel:** `/ticketpanel partner_role:@role`",
18161816
inline=False
18171817
)
18181818
else:

0 commit comments

Comments
 (0)