Skip to content

Commit

Permalink
Help Update, Task Start
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoz committed Oct 16, 2024
1 parent 0ffcdb0 commit d1acb66
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.
1 change: 1 addition & 0 deletions cogs/economy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self, bot):
self.bot.loop.create_task(init_db())
self.bot.loop.create_task(self.load_config())
self.refresh_settings.start()
self.clear_old_cooldowns.start()
self.work_cooldown = {}
self.daily_cooldown = {}
self.economy_config = {}
Expand Down
7 changes: 6 additions & 1 deletion cogs/giveaway.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,9 @@ async def end_giveaway(self, view, giveaway_message):
print(f"Error ending giveaway: {e}")

def setup(bot):
bot.add_cog(GiveawayCog(bot))
cog = GiveawayCog(bot)
bot.add_cog(cog)

if not hasattr(bot, "all_slash_commands"):
bot.all_slash_commands = []
bot.all_slash_commands.append(cog.giveaway)
39 changes: 27 additions & 12 deletions cogs/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@ async def generate_help_embed(self):
description="List of all available commands.",
color=nextcord.Color.blue(),
)
embed.set_footer(
text=f"{constants.FOOTER_TEXT}: Page {self.current_page + 1}",
icon_url=constants.FOOTER_IMAGE,
)


commands_with_paths = []

for cmd in self.bot.all_slash_commands:
if hasattr(cmd, 'children') and cmd.children:
for subcmd in cmd.children.values():
Expand All @@ -31,6 +26,13 @@ async def generate_help_embed(self):
commands_with_paths.append((cmd.name, cmd))

commands_with_paths.sort(key=lambda x: x[0])
total_pages = (len(commands_with_paths) - 1) // 9 + 1

embed.set_footer(
text=f"{constants.FOOTER_TEXT}: Page {self.current_page + 1}/{total_pages}",
icon_url=constants.FOOTER_IMAGE,
)

start = self.current_page * 9
end = min(start + 9, len(commands_with_paths))

Expand All @@ -50,11 +52,15 @@ async def previous_button_callback(self, button, interaction):

@nextcord.ui.button(label="Next", style=nextcord.ButtonStyle.blurple)
async def next_button_callback(self, button, interaction):
if (self.current_page + 1) * 9 < len(
self.bot.all_slash_commands
if hasattr(self.bot, "all_slash_commands")
else []
):
commands_with_paths = []
for cmd in self.bot.all_slash_commands:
if hasattr(cmd, 'children') and cmd.children:
for subcmd in cmd.children.values():
commands_with_paths.append((f"{cmd.name} {subcmd.name}", subcmd))
elif not hasattr(cmd, 'children') or not cmd.children:
commands_with_paths.append((cmd.name, cmd))

if (self.current_page + 1) * 9 < len(commands_with_paths):
self.current_page += 1
await self.update_help_message(interaction)

Expand Down Expand Up @@ -129,4 +135,13 @@ async def about(self, interaction: nextcord.Interaction):
await interaction.response.send_message(embed=embed, view=view, ephemeral=True)

def setup(bot):
bot.add_cog(HelpCog(bot))
cog = HelpCog(bot)
bot.add_cog(cog)
if not hasattr(bot, "all_slash_commands"):
bot.all_slash_commands = []
bot.all_slash_commands.extend(
[
cog.help,
cog.about,
]
)
6 changes: 5 additions & 1 deletion cogs/playerlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,8 @@ def setup(bot):
bot.add_cog(cog)
if not hasattr(bot, "all_slash_commands"):
bot.all_slash_commands = []
bot.all_slash_commands.append(cog.playerslist)
bot.all_slash_commands.extend(
[
cog.playerslist
]
)

0 comments on commit d1acb66

Please sign in to comment.