async def show(self, ctx: commands.Context) -> None: """Display current WA roster in flippable format.""" rosterdict = await self._roster_map() if rosterdict: tostring = json.dumps(rosterdict, sort_keys=True, indent=0) nav = pag.EmbedNavigatorFactory(max_lines=30, prefix="__**TITO Roster**__", enable_truncation=True) nav += (tostring.strip("{}").replace('":', "\n").replace( '",', "\n").replace('"', "**").rstrip("\n").rstrip("*")) nav.start(ctx) else: await ctx.send("Roster is empty.")
async def serverlist(self, ctx): """Shows a list of servers that the bot is in along with member count""" @pag.embed_generator(max_chars=2048) def main_embed(paginator, page, page_index): servlist = discord.Embed(title=f"Servers that I am in", description=page, color=0x00FF00) servlist.set_footer( text=f"{len(self.bot.guilds)} Servers in total.") return servlist navi = pag.EmbedNavigatorFactory(factory=main_embed) servers = [] for guild in self.bot.guilds: servers.append(f"**{guild.name}** (ID:{guild.id})") navi += "\n".join(servers) navi.start(ctx)
async def bans(self, ctx): """See a list of banned users in the guild""" bans = await ctx.guild.bans() banned = [] @pag.embed_generator(max_chars=2048) def det_embed(paginator, page, page_index): em = discord.Embed(title=f"List of Banned Members:", description=page) em.set_footer(text=f"{len(bans)} Members in Total.") return em page = pag.EmbedNavigatorFactory(factory=det_embed) for users in bans: banned.append(str(users.user)) page += "\n".join(banned) page.start(ctx)
async def serverinfo_inrole(self, ctx, *, role: libneko.converters.RoleConverter = None): """ Show the list of users on a particular role. """ if str(role.colour) == "#000000": color = discord.Color(0x99AAB5) else: color = role.colour if role is None: await ctx.send( discord.Embed(description="⚠ Please specify the role.")) else: @pag.embed_generator(max_chars=2048) def det_embed(paginator, page, page_index): embed = discord.Embed(description=page, title=f"Members on `{role.name}` role:", color=color, timestamp=datetime.utcnow()) embed.set_footer( text=f"{str(len(role.members))} Members in Total.") return embed lst = pag.EmbedNavigatorFactory(factory=det_embed) members = [] try: for user in role.members: members.append(f"{user.name}#{user.discriminator}") except discord.Forbidden: await ctx.send(embed=discord.Embed( description= "⚠ Role cannot be found or i dont have permission!")) return lst += "\n".join(members) lst.start(ctx)
async def get_lyrics(self, ctx, *, query: str): spaceReplacedQuery = query.replace(" ", "%20") if randint(0, 100) == 100: owoCheck = True else: owoCheck = False lyricsLink = f"https://some-random-api.ml/lyrics/?title={spaceReplacedQuery}&cancer={owoCheck}" async with request("GET", lyricsLink, headers={}) as response: if response.status == 200: data = await response.json() thumbnail = data["thumbnail"]["genius"] link = data["links"]["genius"] author = data["author"] title = data["title"] @pag.embed_generator(max_chars=2048) def cooler_embed(paginator, page, page_index): embed = Embed(title=f"{author} - {title}", description=page, url=link, colour=ctx.author.colour) embed.set_thumbnail(url=thumbnail) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url) embed.set_footer(text="Such lyrics! Such Moods!", icon_url=ctx.guild.icon_url) return embed nav = pag.EmbedNavigatorFactory(factory=cooler_embed, max_lines=20) nav += data['lyrics'] nav.start(ctx) else: await ctx.send(f"{ctx.author.mention}, something went wrong!")
async def item_search(self, ctx, itemID: int): spriteURL = f'https://www.shining-moon.com/hel/data/items/images/{itemID}.png' URL = f'https://www.shining-moon.com/hel/?module=item&action=view&id={itemID}' async with request("GET", URL, headers={'User-Agent': 'Mozilla/5.0'}) as response: if response.status == 200: html = await response.read() else: await ctx.send(f'Beep Boop\n{response.status} status') soup = BeautifulSoup(html.decode('utf-8'), 'lxml') table = soup.find_all('table', class_='vertical-table')[0] nameRow = table.find_all('tr')[2] name = nameRow.find_all('td')[0] dDiv = soup.find_all('div', class_='inner')[0] dTable = dDiv.find('table') descString = dTable.text.strip() @pag.embed_generator(max_chars=2048) def cooler_embed(paginator, page, page_index): embed = Embed(title=f'**{name.text.strip()}**', description=page, colour=ctx.author.colour, url=URL) embed.set_thumbnail(url=spriteURL) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url) embed.set_footer(text="Taken from Lunar's basement", icon_url=ctx.guild.icon_url) return embed nav = pag.EmbedNavigatorFactory(factory=cooler_embed, max_lines=20) nav += descString nav.start(ctx)
async def leaderboard(ctx): with open('leaderboard.json', 'r') as f: leaderboardFile = json.load(f) sortedDict = { k: v for k, v in sorted(leaderboardFile.items(), key=lambda item: item[1], reverse=True) } nav = pag.EmbedNavigatorFactory(factory=leaderboard_embed, max_lines=20) for player in sortedDict: if sortedDict[player] % 99 == 0: level = 99 stars = (sortedDict[player] // 99 - 1) * '★' else: level = sortedDict[player] % 99 stars = sortedDict[player] // 99 * '★' nav += f'{player} - {level} ★{stars} \n' nav.start(ctx)
async def bans(self, ctx): """See a list of banned users in the guild""" try: bans = await ctx.guild.bans() except: return await ctx.send("You dont have the perms to see bans.") banned = "" @pag.embed_generator(max_chars=2048) def det_embed(paginator, page, page_index): em = discord.Embed(title=f"List of Banned Members:", description=page) em.set_footer(text=f"{len(bans)} Members in Total.") return em page = pag.EmbedNavigatorFactory(factory=det_embed) for users in bans: banned += f"{users.user}\n" page += banned page.start(ctx)
async def serverinfo_boost(self, ctx): """ Show the list of Nitro booster on this server. """ @pag.embed_generator(max_chars=2048) def main_embed(paginator, page, page_index): boost = discord.Embed( title=f"Nitro Booster on **{ctx.guild.name}**.", description=page, color=0x00FF00) boost.set_footer( text= f"{len(ctx.guild.premium_subscribers)} Users in total ({ctx.guild.premium_subscription_count} Boost(s))" ) return boost navi = pag.EmbedNavigatorFactory(factory=main_embed) boosters = [] for x in ctx.guild.premium_subscribers: boosters.append(f"{x} ({x.mention})") navi += "\n".join(boosters) navi.start(ctx)
async def userinfo_shared( self, ctx, user: libneko.converters.InsensitiveUserConverter, user2: libneko.converters.InsensitiveUserConverter): """ See all the servers that you shared with the someone else """ @pag.embed_generator(max_chars=2048) def main_embed(paginator, page, page_index): embed = discord.Embed( title=f'Servers that {user} and {user2} shared with', description=page, color=ctx.message.author.color) return embed pagi = pag.EmbedNavigatorFactory(factory=main_embed) shared = [] for guild in self.bot.guilds: if user in guild.members: if user2 in guild.members: shared.append(guild.name) pagi += "\n".join(shared) pagi.start(ctx)
async def plancan(self, ctx): """Rules and information regarding PlanCan""" nav = pag.EmbedNavigatorFactory(max_lines=10) nav += plancan nav.start(ctx)
async def skybot(self, ctx): """A quick and organized help menu for Skybot""" nav = pag.EmbedNavigatorFactory(max_lines=10) nav += dummy_text nav.start(ctx)