async def dailies(self, ctx): await functions.dailyCommandCounter("dailies") await functions.globalCommandCounter("dailies") await functions.commandCounter(ctx.author.id, "dailies") with open("eso_bot/assets/dailies.json", "r", encoding="utf-8") as dailies: data = json.load(dailies)[0] daily_rewards_1 = discord.Embed(title="Daily Rewards (Day 1-15)", colour=functions.embedColour( ctx.guild.id)) for day in data["rewards"][:15]: daily_rewards_1.add_field( name=f"Day {day['day']}", value=f"{day['reward']} {self.bot.get_emoji(day['emoji'])}", ) daily_rewards_1.set_footer(text=data["date"]) daily_rewards_2 = discord.Embed( title="Daily Rewards (Day 15-30)", colour=functions.embedColour(ctx.guild.id), ) for day in data["rewards"][15:]: daily_rewards_2.add_field( name=f"Day {day['day']}", value=f"{day['reward']} {self.bot.get_emoji(day['emoji'])}", ) daily_rewards_2.set_footer(text=data["date"]) await ctx.send(embed=daily_rewards_1) return await ctx.send(embed=daily_rewards_2)
async def profile(self, ctx, user: discord.Member = None): if user: id = user.id else: id = ctx.author.id descriptionList = "" c.execute(""" SELECT command, times FROM logging WHERE user_id = ? """, (id, )) result = c.fetchall() for command in result: descriptionList += f"`{command[0]}`: used {command[1]} times\n" c.execute(""" SELECT command FROM mostRecent WHERE user_id = ? """, (ctx.author.id, )) mostRecentCommand = c.fetchall() if user: embed = discord.Embed( description=f"{descriptionList}", colour=functions.embedColour(ctx.message.guild.id), ) else: embed = discord.Embed( description=f"{descriptionList}", colour=functions.embedColour(ctx.message.guild.id), ) if not result: embed.add_field(name="Most Used Command", value="None", inline=False) else: def sortSecond(val): return val[1] result.sort(key=sortSecond, reverse=True) embed.add_field(name="Most Used Command", value=f"{result[0][0]}", inline=False) if mostRecentCommand: commandUsed = mostRecentCommand[0][0] embed.add_field(name="Most Recent Command", value=f"{commandUsed}", inline=False) else: embed.add_field(name="Most Recent Command", value="None", inline=False) embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url) embed.set_thumbnail(url=ctx.author.avatar_url) await ctx.send(embed=embed)
async def counter(self, ctx): descriptionList = "" c.execute(""" SELECT command, times FROM globalLogging """) result = c.fetchall() for command in result: descriptionList += f"`{command[0]}`: used {command[1]} times\n" embed = discord.Embed( description=f"{descriptionList}", colour=functions.embedColour(ctx.message.guild.id), ) if not result: embed.add_field(name="Most Used Command", value="None", inline=False) else: def sortSecond(val): return val[1] result.sort(key=sortSecond, reverse=True) embed.add_field(name="Most Used Command", value=f"{result[0][0]}", inline=False) embed.set_author(name=ctx.guild, icon_url=ctx.guild.icon_url) embed.set_thumbnail(url=ctx.guild.icon_url) await ctx.send(embed=embed)
async def handle_reaction(reaction, msg, check): await msg.remove_reaction(reaction, ctx.message.author) reactionIndex = reactions.index(str(reaction.emoji)) if str(reaction.emoji) == reactions[reactionIndex]: help_embed = discord.Embed( title=f"{reactionsCogs[reactionIndex]} Help", colour=functions.embedColour(ctx.guild.id), ) help_embed.set_footer( text= f"Requested by {ctx.message.author.name} :: {ctx.message.guild}'s prefix currently " f"is {currentPrefix}", icon_url=self.bot.user.avatar_url, ) cog_commands = self.bot.get_cog( f"{reactionsCogs[reactionIndex]}").get_commands() commands_list = "" for comm in cog_commands: commands_list += f"**{comm.name}** - {comm.description}\n" help_embed.add_field(name=comm, value=comm.description, inline=True) await msg.edit(embed=help_embed) else: return reaction, user = await self.bot.wait_for("reaction_add", check=check, timeout=30) await handle_reaction(reaction, msg, check)
async def links(self, ctx): await functions.dailyCommandCounter("links") await functions.globalCommandCounter("links") await functions.commandCounter(ctx.author.id, "links") timezone = pytz.timezone("Europe/Amsterdam") time = timezone.localize(datetime.datetime.now()) embed = discord.Embed( title="Links", description= "https://eso-hub.com/\nhttps://elderscrollsonline.wiki.fextralife.com/Elder+Scrolls+Online+Wiki" + "\nhttps://alcasthq.com/", timestamp=time, colour=functions.embedColour(ctx.guild.id), ) return await ctx.send(embed=embed)
async def status(self, ctx): await functions.dailyCommandCounter("status") await functions.globalCommandCounter("status") await functions.commandCounter(ctx.author.id, "status") status_embed = discord.Embed(title="Status", colour=functions.embedColour( ctx.guild.id)) members = len(list(self.bot.get_all_members())) uptime = datetime.datetime.now() - self.bot.start_time uptime = datetime.timedelta(days=uptime.days, seconds=uptime.seconds) date = "**Created on:** 30-9-2018" status_embed.description = "\n".join([ f"Bot up and running in {len(self.bot.guilds)} guilds with {members} members.", f"**Uptime:** {uptime}\n{date}", "For more help or information join our [support server](https://discord.gg/5xvAHhU)", ]) status_embed.set_author(name=f"{ctx.author}", icon_url=ctx.author.avatar_url) status_embed.set_footer( text="Use !help to get a list of available commands.") return await ctx.send(embed=status_embed)
async def handle_rotate(reaction, msg, check): global reactionIndex await msg.remove_reaction(reaction, ctx.message.author) try: reactionIndex = reacts.index(str(reaction.emoji)) except Exception as e: print(str(e)) if ( str(reaction.emoji) == reacts[reactionIndex] and not str(reaction.emoji) == "📖" ): editEmbed = discord.Embed( title=f"{data[reactionIndex]['dungeon']}", url=f"{data[reactionIndex]['link']}", description=f"{data[reactionIndex]['description']}\n\nFor more " f"information on the bosses, please react on the book!", colour=functions.embedColour(ctx.guild.id), ) setList = "" nameList = "" for sets in data[reactionIndex]["sets"]: setList += f"{sets}\n" editEmbed.add_field(name="Sets", value=f"{setList}") for names in data[reactionIndex]["bosses"]: nameList += f'{names["name"]}\n' editEmbed.set_image(url=f"{data[reactionIndex]['image']}") editEmbed.add_field(name="Bosses", value=f"{nameList}") editEmbed.set_footer( text="Image from Elder Scrolls Online Wiki", icon_url=ctx.author.avatar_url, ) await msg.edit(embed=editEmbed) await msg.add_reaction("📖") elif str(reaction.emoji) == "📖": bossesName = [] bossesMechanics = [] bossesStrategy = [] await msg.clear_reactions() j = 0 for bossName in data[reactionIndex]["bosses"]: bossesName.append(bossName["name"]) bossesMechanics.append(bossName["mechanics"]) bossesStrategy.append(bossName["strategy"]) mechanics = "" strategies = "" for mechanic in bossesMechanics[j]: mechanics += f"{mechanic}\n" for strategy in bossesStrategy[j]: strategies += f"{strategy}\n" if len(mechanics) < 1024 and len(strategies) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field(name="Mechanics", value=f"{mechanics}") bossEmbed.add_field(name="Strategy", value=f"{strategies}") elif len(strategies) < 1024 and not len(mechanics) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Mechanics**\n{mechanics}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field(name="Strategy", value=f"{strategies}") else: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Strategy**\n{strategies}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field(name="Mechanics", value=f"{mechanics}") await msg.edit(embed=bossEmbed) await msg.add_reaction("◀️") await msg.add_reaction("▶️") def check3(reaction, user): return ( str(reaction.emoji) in ["◀️", "▶️"] and user == ctx.message.author and reaction.message.id == msg.id ) j = 0 async def handle_rotate3(reaction, msg, check, j): await msg.remove_reaction(reaction, ctx.message.author) if str(reaction.emoji) == "◀️": j -= 1 try: mechanics = "" strategies = "" for mechanic in bossesMechanics[j]: mechanics += f"{mechanic}\n" for strategy in bossesStrategy[j]: strategies += f"{strategy}\n" if len(mechanics) < 1024 and len(strategies) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) elif ( len(strategies) < 1024 and not len(mechanics) < 1024 ): bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Mechanics**\n{mechanics}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) else: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Strategy**\n{strategies}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) await msg.edit(embed=bossEmbed) except IndexError: embed = discord.Embed( description="You've reached the end of the pages! Press ◀️ to go back!" ) await msg.edit(embed=embed) elif str(reaction.emoji) == "▶️": j += 1 try: mechanics = "" strategies = "" for mechanic in bossesMechanics[j]: mechanics += f"{mechanic}\n" for strategy in bossesStrategy[j]: strategies += f"{strategy}\n" if len(mechanics) < 1024 and len(strategies) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) elif ( len(strategies) < 1024 and not len(mechanics) < 1024 ): bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Mechanics**\n{mechanics}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) else: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Strategy**\n{strategies}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) await msg.edit(embed=bossEmbed) except IndexError: embed = discord.Embed( description="You've reached the end of the pages! Press ◀️ to go back!" ) await msg.edit(embed=embed) else: return reaction, user = await self.bot.wait_for( "reaction_add", check=check3 ) await handle_rotate3(reaction, msg, check, j) reaction, user = await self.bot.wait_for( "reaction_add", check=check3 ) await handle_rotate3(reaction, msg, check, j) reaction, user = await self.bot.wait_for("reaction_add", check=check) await handle_rotate(reaction, msg, check)
async def set(self, ctx, *set): """ Lookup information on any set. """ await command_invoked(self.bot, "set", ctx.author.name) with open("eso_bot/assets/sets.json", "r", encoding="utf-8") as dungeons: data = json.load(dungeons) result = False set_ = " ".join(set) if len(set_) < 3: return await ctx.send("Your search request must be at least 3 characters.") for x in data: if set_.lower() == x["name"].lower(): result = True description = "" for index, effect in enumerate(x["effects"]): description += f"**{index + 2} items:** {effect}\n" embed = discord.Embed( title=x["name"], description=description, url=x["link"], colour=functions.embedColour(ctx.guild.id), ) embed.set_thumbnail(url=x["image"]) embed.set_footer(text="Sets and icons © by ZeniMax Online Studios") return await ctx.send(embed=embed) if result is False: reference_sets = [] results = "" timezone = pytz.timezone("Europe/Amsterdam") time = timezone.localize(datetime.datetime.now()) for x in data: if set_.lower() in x["name"].lower(): reference_sets.append(x["name"]) if len(reference_sets) == 1: return await ctx.invoke(self.set, reference_sets[0]) elif len(reference_sets) > 0: loaded_sets = reference_sets elif len(reference_sets) == 0: return await ctx.send( f"No results were found matching your request: `{set_}`" ) else: loaded_sets = [x["name"] for x in data] for index, x in enumerate(loaded_sets): results += f"`{index + 1}` {x} \n" embed = discord.Embed( title="Sets", description=f"`{set_}` was not found.\nDid you mean one of the following " f"dungeons:\n{results}\nReply " f"with a number for more information.", colour=functions.embedColour(ctx.guild.id), timestamp=time, ) await ctx.send(embed=embed) def check(m): return ( m.content in [str(i) for i in range(1, len(loaded_sets) + 1)] and m.channel == ctx.channel and ctx.author == m.author ) try: choice = await ctx.bot.wait_for("message", timeout=10.0, check=check) except asyncio.TimeoutError: return await ctx.send("Request timed out.") if choice: set = f"{loaded_sets[int(choice.content) - 1].lower()}" await ctx.send(f"!set {set}") async with ctx.typing(): return await ctx.invoke(self.set, set)
async def handle_rotate3(reaction, msg, check, j): await msg.remove_reaction(reaction, ctx.message.author) if str(reaction.emoji) == "◀️": j -= 1 try: mechanics = "" strategies = "" for mechanic in bossesMechanics[j]: mechanics += f"{mechanic}\n" for strategy in bossesStrategy[j]: strategies += f"{strategy}\n" if len(mechanics) < 1024 and len(strategies) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) elif len(strategies) < 1024 and not len(mechanics) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Mechanics**\n{mechanics}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) else: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Strategy**\n{strategies}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) await msg.edit(embed=bossEmbed) except IndexError: embed = discord.Embed( description="You've reached the end of the pages! Press ◀️ to go back!" ) await msg.edit(embed=embed) elif str(reaction.emoji) == "▶️": j += 1 try: mechanics = "" strategies = "" for mechanic in bossesMechanics[j]: mechanics += f"{mechanic}\n" for strategy in bossesStrategy[j]: strategies += f"{strategy}\n" if len(mechanics) < 1024 and len(strategies) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) elif len(strategies) < 1024 and not len(mechanics) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Mechanics**\n{mechanics}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) else: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Strategy**\n{strategies}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) await msg.edit(embed=bossEmbed) except IndexError: embed = discord.Embed( description="You've reached the end of the pages! Press ◀️ to go back!" ) await msg.edit(embed=embed) else: return reaction, user = await self.bot.wait_for( "reaction_add", check=check3 ) await handle_rotate3(reaction, msg, check, j)
async def dungeon(self, ctx, *, dungeon=None): with open("eso_bot/assets/dungeons.json", "r", encoding="utf-8") as dungeons: data = json.load(dungeons) if not dungeon: reacts = ["🇦", "🇧", "🇨", "🇩", "🇪", "🇫", "🇬", "🇭"] dungeonsList = "" i = 0 for dungeon in data: dungeonsList += f"`{reacts[i]}` {dungeon['dungeon']}\n" i += 1 embed = discord.Embed( title="Dungeons List", description=f"Please select from one of the following dungeons:\n{dungeonsList}", colour=functions.embedColour(ctx.guild.id), ) embed.set_footer( text=f"Requested by {ctx.message.author}", icon_url=ctx.author.avatar_url, ) msg = await ctx.send(embed=embed) for number in reacts: await msg.add_reaction(number) def check(reaction, user): reactCheck = ["🇦", "🇧", "🇨", "🇩", "🇪", "🇫", "🇬", "🇭", "📖"] return ( str(reaction.emoji) in reactCheck and user == ctx.message.author and reaction.message.id == msg.id ) async def handle_rotate(reaction, msg, check): global reactionIndex await msg.remove_reaction(reaction, ctx.message.author) try: reactionIndex = reacts.index(str(reaction.emoji)) except Exception as e: print(str(e)) if ( str(reaction.emoji) == reacts[reactionIndex] and not str(reaction.emoji) == "📖" ): editEmbed = discord.Embed( title=f"{data[reactionIndex]['dungeon']}", url=f"{data[reactionIndex]['link']}", description=f"{data[reactionIndex]['description']}\n\nFor more " f"information on the bosses, please react on the book!", colour=functions.embedColour(ctx.guild.id), ) setList = "" nameList = "" for sets in data[reactionIndex]["sets"]: setList += f"{sets}\n" editEmbed.add_field(name="Sets", value=f"{setList}") for names in data[reactionIndex]["bosses"]: nameList += f'{names["name"]}\n' editEmbed.set_image(url=f"{data[reactionIndex]['image']}") editEmbed.add_field(name="Bosses", value=f"{nameList}") editEmbed.set_footer( text="Image from Elder Scrolls Online Wiki", icon_url=ctx.author.avatar_url, ) await msg.edit(embed=editEmbed) await msg.add_reaction("📖") elif str(reaction.emoji) == "📖": bossesName = [] bossesMechanics = [] bossesStrategy = [] await msg.clear_reactions() j = 0 for bossName in data[reactionIndex]["bosses"]: bossesName.append(bossName["name"]) bossesMechanics.append(bossName["mechanics"]) bossesStrategy.append(bossName["strategy"]) mechanics = "" strategies = "" for mechanic in bossesMechanics[j]: mechanics += f"{mechanic}\n" for strategy in bossesStrategy[j]: strategies += f"{strategy}\n" if len(mechanics) < 1024 and len(strategies) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field(name="Mechanics", value=f"{mechanics}") bossEmbed.add_field(name="Strategy", value=f"{strategies}") elif len(strategies) < 1024 and not len(mechanics) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Mechanics**\n{mechanics}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field(name="Strategy", value=f"{strategies}") else: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Strategy**\n{strategies}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field(name="Mechanics", value=f"{mechanics}") await msg.edit(embed=bossEmbed) await msg.add_reaction("◀️") await msg.add_reaction("▶️") def check3(reaction, user): return ( str(reaction.emoji) in ["◀️", "▶️"] and user == ctx.message.author and reaction.message.id == msg.id ) j = 0 async def handle_rotate3(reaction, msg, check, j): await msg.remove_reaction(reaction, ctx.message.author) if str(reaction.emoji) == "◀️": j -= 1 try: mechanics = "" strategies = "" for mechanic in bossesMechanics[j]: mechanics += f"{mechanic}\n" for strategy in bossesStrategy[j]: strategies += f"{strategy}\n" if len(mechanics) < 1024 and len(strategies) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) elif ( len(strategies) < 1024 and not len(mechanics) < 1024 ): bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Mechanics**\n{mechanics}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) else: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Strategy**\n{strategies}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) await msg.edit(embed=bossEmbed) except IndexError: embed = discord.Embed( description="You've reached the end of the pages! Press ◀️ to go back!" ) await msg.edit(embed=embed) elif str(reaction.emoji) == "▶️": j += 1 try: mechanics = "" strategies = "" for mechanic in bossesMechanics[j]: mechanics += f"{mechanic}\n" for strategy in bossesStrategy[j]: strategies += f"{strategy}\n" if len(mechanics) < 1024 and len(strategies) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) elif ( len(strategies) < 1024 and not len(mechanics) < 1024 ): bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Mechanics**\n{mechanics}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) else: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Strategy**\n{strategies}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) await msg.edit(embed=bossEmbed) except IndexError: embed = discord.Embed( description="You've reached the end of the pages! Press ◀️ to go back!" ) await msg.edit(embed=embed) else: return reaction, user = await self.bot.wait_for( "reaction_add", check=check3 ) await handle_rotate3(reaction, msg, check, j) reaction, user = await self.bot.wait_for( "reaction_add", check=check3 ) await handle_rotate3(reaction, msg, check, j) reaction, user = await self.bot.wait_for("reaction_add", check=check) await handle_rotate(reaction, msg, check) reaction, user = await self.bot.wait_for("reaction_add", check=check) await handle_rotate(reaction, msg, check) elif dungeon: dungeonsList = [] for d in data: dungeonsList.append(d["dungeon"]) inputIndex = dungeonsList.index(dungeon) if dungeon not in dungeonsList: await functions.requestEmbedTemplate( ctx, "The dungeon name you've entered does not exist! Please check your spelling (case sensitive).", ctx.message.author, ) return embed = discord.Embed( title=f"{data[inputIndex]['dungeon']}", url=f"{data[inputIndex]['link']}", description=f"{data[inputIndex]['description']}\n\nFor more information on the bosses, please " f"react on the book!", colour=functions.embedColour(ctx.guild.id), ) setList = "" nameList = "" for sets in data[inputIndex]["sets"]: setList += f"{sets}\n" embed.add_field(name="Sets", value=f"{setList}") for names in data[inputIndex]["bosses"]: nameList += f'{names["name"]}\n' embed.set_image(url=f"{data[inputIndex]['image']}") embed.add_field(name="Bosses", value=f"{nameList}") embed.set_footer( text="Image from Elder Scrolls Online Wiki", icon_url=ctx.author.avatar_url, ) msg = await ctx.send(embed=embed) await msg.add_reaction("📖") def check(reaction, user): return ( str(reaction.emoji) in ["📖"] and user == ctx.message.author and reaction.message.id == msg.id ) reaction, user = await self.bot.wait_for("reaction_add", check=check) if str(reaction.emoji) == "📖": bossesName = [] bossesMechanics = [] bossesStrategy = [] await msg.clear_reactions() j = 0 for bossName in data[inputIndex]["bosses"]: bossesName.append(bossName["name"]) bossesMechanics.append(bossName["mechanics"]) bossesStrategy.append(bossName["strategy"]) mechanics = "" strategies = "" for mechanic in bossesMechanics[j]: mechanics += f"{mechanic}\n" for strategy in bossesStrategy[j]: strategies += f"{strategy}\n" if len(mechanics) < 1024 and len(strategies) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field(name="Mechanics", value=f"{mechanics}") bossEmbed.add_field(name="Strategy", value=f"{strategies}") elif len(strategies) < 1024 and not len(mechanics) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Mechanics**\n{mechanics}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field(name="Strategy", value=f"{strategies}") else: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Strategy**\n{strategies}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field(name="Mechanics", value=f"{mechanics}") await msg.edit(embed=bossEmbed) await msg.add_reaction("◀️") await msg.add_reaction("▶️") def check3(reaction, user): return ( str(reaction.emoji) in ["◀️", "▶️"] and user == ctx.message.author and reaction.message.id == msg.id ) j = 0 async def handle_rotate3(reaction, msg, check, j): await msg.remove_reaction(reaction, ctx.message.author) if str(reaction.emoji) == "◀️": j -= 1 try: mechanics = "" strategies = "" for mechanic in bossesMechanics[j]: mechanics += f"{mechanic}\n" for strategy in bossesStrategy[j]: strategies += f"{strategy}\n" if len(mechanics) < 1024 and len(strategies) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) elif len(strategies) < 1024 and not len(mechanics) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Mechanics**\n{mechanics}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) else: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Strategy**\n{strategies}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) await msg.edit(embed=bossEmbed) except IndexError: embed = discord.Embed( description="You've reached the end of the pages! Press ◀️ to go back!" ) await msg.edit(embed=embed) elif str(reaction.emoji) == "▶️": j += 1 try: mechanics = "" strategies = "" for mechanic in bossesMechanics[j]: mechanics += f"{mechanic}\n" for strategy in bossesStrategy[j]: strategies += f"{strategy}\n" if len(mechanics) < 1024 and len(strategies) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) elif len(strategies) < 1024 and not len(mechanics) < 1024: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Mechanics**\n{mechanics}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Strategy", value=f"{strategies}" ) else: bossEmbed = discord.Embed( title=f"{bossesName[j]}", description=f"**Strategy**\n{strategies}", colour=functions.embedColour(ctx.guild.id), ) bossEmbed.add_field( name="Mechanics", value=f"{mechanics}" ) await msg.edit(embed=bossEmbed) except IndexError: embed = discord.Embed( description="You've reached the end of the pages! Press ◀️ to go back!" ) await msg.edit(embed=embed) else: return reaction, user = await self.bot.wait_for( "reaction_add", check=check3 ) await handle_rotate3(reaction, msg, check, j) reaction, user = await self.bot.wait_for("reaction_add", check=check3) await handle_rotate3(reaction, msg, check, j)
async def help(self, ctx): await functions.dailyCommandCounter("help") await functions.globalCommandCounter("help") await functions.commandCounter(ctx.author.id, "help") reactions = ["🌴", "🛠️", "❓"] reactionsCogs = ["🌴 Lookup", "🛠️ Settings", "❓ Information"] cogs = [cog for cog in self.bot.cogs.keys()] prefixDictionary = {} for prefix in c.execute("SELECT guild_id, prefix FROM prefix"): prefixDictionary.update({prefix[0]: f"{prefix[1]}"}) currentPrefix = prefixDictionary[ctx.message.guild.id] embed = discord.Embed( title="Bot Help Menu", description= f"`{currentPrefix}myprefix` for this server's prefix and `{currentPrefix}setprefix` " f"to change this server's prefix.", colour=functions.embedColour(ctx.guild.id), ) # embed.set_thumbnail(url="https://i.imgur.com/3Lgs39V.png") embed.set_footer( text= f"Requested by {ctx.message.author.name} :: {ctx.message.guild}'s prefix currently is {currentPrefix}", icon_url=self.bot.user.avatar_url, ) hidden_cogs = ["Help", "Functions"] for cog in cogs: if cog not in hidden_cogs: try: cog_commands = self.bot.get_cog(cog).get_commands() commands_list = "" for comm in cog_commands: commands_list += f"`{comm}` " embed.add_field(name=cog, value=commands_list, inline=True) except Exception as e: print(str(e)) msg = await ctx.send(embed=embed) for react in reactions: await msg.add_reaction(react) def check(reaction, user): return (str(reaction.emoji) in reactions and user == ctx.message.author and reaction.message.id == msg.id) async def handle_reaction(reaction, msg, check): await msg.remove_reaction(reaction, ctx.message.author) reactionIndex = reactions.index(str(reaction.emoji)) if str(reaction.emoji) == reactions[reactionIndex]: help_embed = discord.Embed( title=f"{reactionsCogs[reactionIndex]} Help", colour=functions.embedColour(ctx.guild.id), ) help_embed.set_footer( text= f"Requested by {ctx.message.author.name} :: {ctx.message.guild}'s prefix currently " f"is {currentPrefix}", icon_url=self.bot.user.avatar_url, ) cog_commands = self.bot.get_cog( f"{reactionsCogs[reactionIndex]}").get_commands() commands_list = "" for comm in cog_commands: commands_list += f"**{comm.name}** - {comm.description}\n" help_embed.add_field(name=comm, value=comm.description, inline=True) await msg.edit(embed=help_embed) else: return reaction, user = await self.bot.wait_for("reaction_add", check=check, timeout=30) await handle_reaction(reaction, msg, check) reaction, user = await self.bot.wait_for("reaction_add", check=check, timeout=30) await handle_reaction(reaction, msg, check)