Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @commands.slash_command(
- name = "help",
- description = "Returns a paginator embed of all available bot commands based off your top role",
- guild_ids=[JsonService().get_guild_id()]
- )
- @commands.has_any_role("member")
- async def help(self, inter):
- await inter.response.defer(ephemeral=True)
- gen_commands = self.json_service.get_gen_commands()
- staff_commands = self.json_service.get_staff_commands()
- owner_role_id = self.json_service.get_owner_id()
- admin_role_id = self.json_service.get_admin_id()
- mod_role_id = self.json_service.get_mod_id()
- user_top_role_id = inter.author.top_role.id
- embed = disnake.Embed(
- color = disnake.Colour.random(),
- title = f"{inter.guild.name}'s Help Command",
- description = "In the following pages you will see the help commands available to you based off your highest ranking role."
- ).set_footer(
- text = "If you encounter problems with this command, please run `/report`"
- ).set_thumbnail(url = inter.guild.icon)
- gen_embeds = self.build_embeds(gen_commands)
- staff_embeds = self.build_embeds(staff_commands)
- all_embeds = [embed]
- if user_top_role_id in [owner_role_id, admin_role_id, mod_role_id]:
- all_embeds.append(gen_embeds)
- all_embeds.append(staff_embeds)
- else:
- all_embeds.append(gen_embeds)
- return await inter.edit_original_message(
- embed = all_embeds[0],
- view = Pagination(
- embeds = all_embeds
- )
- )
- def build_embeds(self, list_of_commands):
- return_embeds = []
- for item in list_of_commands:
- name = item
- action = list_of_commands[item]["command"]
- descr = list_of_commands[item]["description"]
- examples = '\n'.join(list_of_commands[item]["examples"])
- embed = disnake.Embed(
- color = disnake.Colour.random(),
- title = name,
- description = descr
- ).add_field(
- name = action,
- value = examples,
- inline = False
- )
- return_embeds.append(embed)
- return return_embeds
Advertisement
Add Comment
Please, Sign In to add comment