def get_help_pages(self, cmd_dict: dict, adminhelp: bool = False) -> list: """Builds paginated help menu""" pages = [] # Overview author=f"Graham v{__version__} ({'BANANO' if Env.banano() else 'WATERMELONANO'}) edition" title="Command Overview" description=("Use `{0}help command` for more information about a specific command " + " or go to the next page").format(config.Config.instance().command_prefix) entries = [] for k, cmd_list in cmd_dict.items(): for cmd in cmd_dict[k]['cmd_list']: entries.append(Entry(f"{config.Config.instance().command_prefix}{cmd.triggers[0]}", cmd.overview)) if adminhelp: entries.append(Entry(f"{config.Config.instance().command_prefix}adminhelp", "View the full list of admin commands")) pages.append(Page(entries=entries, title=title,author=author, description=description)) # Build detail pages for group, details in cmd_dict.items(): author=cmd_dict[group]['header'] description=cmd_dict[group]['info'] entries = self.get_entries(cmd_dict[group]['cmd_list']) pages.append(Page(entries=entries, author=author,description=description)) # Info entries = [Entry(f"{config.Config.instance().command_prefix}{tips.TIPAUTHOR_INFO.triggers[0]}", tips.TIPAUTHOR_INFO.details)] author=f"Graham v{__version__} for {Env.currency_name()}" heart = '\U0001F49B' if Env.banano() else '\U0001F499' description = "This bot is completely free, open source, and MIT licnesed" description+= f"\n\nMade with {heart} for the **BANANO** and **WATERMELONANO** communities" description+= f"\nHangout with some awesome people at https://chat.banano.cc" description+= f"\nMy Discord: **@bbedward#9246**" description+= f"\nMy Reddit: **/u/bbedward**" description+= f"\nMy Twitter: **@theRealBbedward**" description+= f"\n\nGraham GitHub: https://github.com/bbedward/graham_discord_bot" pages.append(Page(entries=entries, author=author,description=description)) return pages
async def favorites_cmd(self, ctx: Context): if ctx.error: return msg = ctx.message user = ctx.user favorited_list = await Favorite.filter(user=ctx.user).prefetch_related('favorited_user').all() if len(favorited_list) < 1: await msg.author.send("You don't have any users in your favorites list.") return # Build user list entries = [] for u in favorited_list: entries.append(Entry(f"{u.favorited_user.name}", f"Remove with `{config.Config.instance().command_prefix}unfavorite {u.favorited_user.id}`")) # Build pages pages = [] # Overview author=f"Your Favorites" description = f"Use `{config.Config.instance().command_prefix}unfavorite <user_id>` to remove a user from your favorites" i = 0 entry_subset = [] for e in entries: entry_subset.append(e) if i == 14: pages.append(Page(entries=entry_subset, author=author, description=description)) i = 0 entry_subset = [] else: i += 1 if len(entry_subset) > 0: pages.append(Page(entries=entry_subset, author=author, description=description)) # Add a bonus page entries = [Entry("Remove all favorites", "Copy and paste the command to remove everybody from your favorites list")] author=f"Remove everybody" description = f"```{config.Config.instance().command_prefix}unfavorite" for u in favorited_list: description += f" {u.favorited_user.id}" description += "```" pages.append(Page(entries=entries, author=author,description=description)) # Start pagination pages = Paginator(self.bot, message=msg, page_list=pages,as_dm=True) await pages.paginate(start_page=1)
def get_entries(self, commands: list) -> list: entries = [] for cmd in commands: entries.append( Entry( f"{config.Config.instance().command_prefix}{cmd.triggers[0]}", cmd.details)) return entries
async def muted_cmd(self, ctx: Context): if ctx.error: return msg = ctx.message user = ctx.user if not ChannelUtil.is_private(msg.channel): await Messages.add_x_reaction(msg) await Messages.send_error_dm(msg.author, "You can only view users you have muted in DM") return muted_list = await Muted.filter(user=ctx.user).prefetch_related('target_user').all() if len(muted_list) < 1: await msg.author.send("You haven't muted anybody.") return # Build user list entries = [] for u in muted_list: entries.append(Entry(f"{u.target_user.name}", f"Unmute with `{config.Config.instance().command_prefix}unmute {u.target_user.id}`")) # Build pages pages = [] # Overview author=f"Muted Users" description = f"Use `{config.Config.instance().command_prefix}unmute <user_id>` to unmute a user" i = 0 entry_subset = [] for e in entries: entry_subset.append(e) if i == 14: pages.append(Page(entries=entry_subset, author=author, description=description)) i = 0 entry_subset = [] else: i += 1 if len(entry_subset) > 0: pages.append(Page(entries=entry_subset, author=author, description=description)) # Start pagination pages = Paginator(self.bot, message=msg, page_list=pages,as_dm=True) await pages.paginate(start_page=1)
async def statsbanned_cmd(self, ctx: Context): if ctx.error: return msg = ctx.message if ChannelUtil.is_private(msg.channel): await Messages.add_x_reaction(msg) await Messages.send_error_dm(msg.author, "You can only view stats banned in a public channel") return banned_list = await Stats.filter(banned=True, server_id=msg.guild.id).prefetch_related('user').all() if len(banned_list) < 1: await msg.author.send("There aren't any banned users") return # Build user list entries = [] for u in banned_list: entries.append(Entry(f"{u.user.id}:{u.user.name}", f"Unban with `{config.Config.instance().command_prefix}statsunban {u.user.id}`")) # Build pages pages = [] # Overview author=f"Stats Banned Users" description = f"Use `{config.Config.instance().command_prefix}statsunban <user_id>` to unban a user" i = 0 entry_subset = [] for e in entries: entry_subset.append(e) if i == 14: pages.append(Page(entries=entry_subset, author=author, description=description)) i = 0 entry_subset = [] else: i += 1 if len(entry_subset) > 0: pages.append(Page(entries=entry_subset, author=author, description=description)) # Start pagination pages = Paginator(self.bot, message=msg, page_list=pages,as_dm=True) await pages.paginate(start_page=1)
async def tipbanned_cmd(self, ctx: Context): if ctx.error: return msg = ctx.message banned_list = await User.filter(tip_banned=True).all() if len(banned_list) < 1: await msg.author.send("There aren't any banned users") return # Build user list entries = [] for u in banned_list: entries.append(Entry(f"{u.id}:{u.name}", f"Unban with `{config.Config.instance().command_prefix}tipunban {u.id}`")) # Build pages pages = [] # Overview author=f"Tip Banned Users" description = f"Use `{config.Config.instance().command_prefix}tipunban <user_id>` to unban a user" i = 0 entry_subset = [] for e in entries: entry_subset.append(e) if i == 14: pages.append(Page(entries=entry_subset, author=author, description=description)) i = 0 entry_subset = [] else: i += 1 if len(entry_subset) > 0: pages.append(Page(entries=entry_subset, author=author, description=description)) # Start pagination pages = Paginator(self.bot, message=msg, page_list=pages,as_dm=True) await pages.paginate(start_page=1)