async def setupAdminMenu(self, ctx, menu): embed = discord.Embed(title='Administrator Module', description="This module contains the following commands.\n\nLIST COMING SOON\n\nOptions:\n0: Enable\n1: Disable\n2: Back to main menu\nx: Closes Menu", colour=self.bot.getcolour()) embed.set_footer(text="Modules for guild: "+ ctx.guild.name +"("+ str(ctx.guild.id)+")") await menu.edit(embed=embed) options = useful.getMenuEmoji(3) def emojiCheck(reaction, user): return (user == ctx.author) and (str(reaction.emoji) in options) try: reaction, user = await self.bot.wait_for('reaction_add', check=emojiCheck, timeout=60.0) except asyncio.TimeoutError: try: await ctx.channel.send(":no_entry: | **" + ctx.author.nick + "** The command menu has closed due to inactivity. Please reuse the modules command to restart the process.") except TypeError: await ctx.channel.send(":no_entry: | **" + ctx.author.name + "** The command menu has closed due to inactivity. Please reuse the modules command to restart the process.") await menu.delete() else: await menu.remove_reaction(reaction.emoji, user) if str(reaction.emoji) == "0\u20e3": await self.enableModule(ctx, "administrator") await self.setupAdminMenu(ctx, menu) elif str(reaction.emoji) == "1\u20e3": await self.disableModule(ctx, "administrator") await self.setupAdminMenu(ctx, menu) elif str(reaction.emoji) == "2\u20e3": await self.setupMainMenu(ctx, menu) elif str(reaction.emoji) == "❌": closed = await ctx.channel.send(":white_check_mark: | Menu closed!") await menu.delete() await asyncio.sleep(1) await closed.delete()
async def setup(self, ctx): embed = discord.Embed(title="Menu Loading...", description="Please stand by.", colour=self.bot.getcolour()) menu = await ctx.channel.send(embed = embed) emojis = useful.getMenuEmoji(10) for emoji in range(0,len(emojis)): await menu.add_reaction(emojis[emoji]) await self.setupMainMenu(ctx, menu)
async def rolePresetQuizMaster(self, ctx, menu, role): embed = discord.Embed(title='Quiz Master preset options', description="This will make this role have quiz master permissions. Are you sure you wish to proceed?\n\nOptions:\n0: Yes\n1: Back\nx: Closes Menu", colour=self.bot.getcolour()) embed.set_footer(text="Current role: "+ role.name +"("+ str(role.id)+")") await menu.edit(embed=embed) options = useful.getMenuEmoji(3) def roles_emojis_admin_menu(reaction, user): return (user == ctx.author) and (str(reaction.emoji) in options) try: reaction, user = await self.bot.wait_for('reaction_add', check=roles_emojis_admin_menu, timeout=60.0) except asyncio.TimeoutError: try: await ctx.channel.send(":no_entry: | **" + ctx.author.nick + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") except TypeError: await ctx.channel.send(":no_entry: | **" + ctx.author.name + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") await menu.delete() else: await menu.remove_reaction(reaction.emoji, user) if str(reaction.emoji) == "0\u20e3": toeditTrue = ["bluetext", "bluetextcode", "cute", "conch", "pqstart", "pqend", "pqquestion", "pqsuperquestion", "pqoverride", "pqsettime", "pqqmhelp"] toeditFalse = ["administrator", "setwelcomechannel", "setwelcometext", "setleavechannel", "setleavetext", "setraidrole", "setraidtext", "editrole", "setmuterole", "mute","toggleraid", "pqjoin"] await self.editRolePermissions(ctx, menu, role, toeditTrue, toeditFalse) await self.rolePresetMenu(ctx, menu, role) elif str(reaction.emoji) == "1\u20e3": await self.rolePresetMenu(ctx, menu, role) elif str(reaction.emoji) == "❌": closed = await ctx.channel.send(":white_check_mark: | Menu closed!") await menu.delete() await asyncio.sleep(1) await closed.delete()
async def roleAdminCommand(self, ctx, menu, role): embed = discord.Embed(title='Admin Permission options', description="The administrator permission allows the role to access all bot commands regardless of other permission levels. This is a very dangerous permission to grant.\n\nOptions:\n0: Enable\n1: Disable\n2: Back\nx: Closes Menu", colour=self.bot.getcolour()) embed.set_footer(text="Current role: "+ role.name +"("+ str(role.id)+")") await menu.edit(embed=embed) options = useful.getMenuEmoji(3) def roles_emojis_admin_menu(reaction, user): return (user == ctx.author) and (str(reaction.emoji) in options) try: reaction, user = await self.bot.wait_for('reaction_add', check=roles_emojis_admin_menu, timeout=60.0) except asyncio.TimeoutError: try: await ctx.channel.send(":no_entry: | **" + ctx.author.nick + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") except TypeError: await ctx.channel.send(":no_entry: | **" + ctx.author.name + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") await menu.delete() else: await menu.remove_reaction(reaction.emoji, user) if str(reaction.emoji) == "0\u20e3": toeditTrue = ["administrator"] toeditFalse = [] await self.editRolePermissions(ctx, menu, role, toeditTrue, toeditFalse) await self.roleAdminCommand(ctx, menu, role) elif str(reaction.emoji) == "1\u20e3": toeditTrue = [] toeditFalse = ["administrator"] await self.editRolePermissions(ctx, menu, role, toeditTrue, toeditFalse) await self.roleAdminCommand(ctx, menu, role) elif str(reaction.emoji) == "2\u20e3": await self.roleAdminMenu(ctx, menu, role) elif str(reaction.emoji) == "❌": closed = await ctx.channel.send(":white_check_mark: | Menu closed!") await menu.delete() await asyncio.sleep(1) await closed.delete()
async def roleNSFWMenu(self, ctx, menu, role): embed = discord.Embed(title='NSFW Permission options', description="These commands allow users to look at lewd images.\n\nOptions:\n0: e621\n1: Back to main menu\nx: Closes Menu", colour=self.bot.getcolour()) embed.set_footer(text="Current role: "+ role.name +"("+ str(role.id)+")") await menu.edit(embed=embed) options = useful.getMenuEmoji(10) def roles_emojis_admin_menu(reaction, user): return (user == ctx.author) and (str(reaction.emoji) in options) try: reaction, user = await self.bot.wait_for('reaction_add', check=roles_emojis_admin_menu, timeout=60.0) except asyncio.TimeoutError: try: await ctx.channel.send(":no_entry: | **" + ctx.author.nick + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") except TypeError: await ctx.channel.send(":no_entry: | **" + ctx.author.name + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") await menu.delete() else: await menu.remove_reaction(reaction.emoji, user) if str(reaction.emoji) == "0\u20e3": permissionToEdit = "esix" await self.roleToggleFunction(ctx, role, menu, permissionToEdit) await self.rolePubQuizMenu(ctx, menu, role) elif str(reaction.emoji) == "1\u20e3": await self.rolesMainMenu(ctx, menu, role) elif str(reaction.emoji) == "❌": closed = await ctx.channel.send(":white_check_mark: | Menu closed!") await menu.delete() await asyncio.sleep(1) await closed.delete()
async def rolesMainMenu(self, ctx, menu, role): embed = discord.Embed(title='Role Permission Main Menu', description="Options:\n0: Admin\n1: NSFW\n2: Pub Quiz\n3: Miscellaneous\n4: Set role to preset permission level\nx: Closes Menu", colour=self.bot.getcolour()) embed.set_footer(text="Current role: "+ role.name +"("+ str(role.id)+")") await menu.edit(embed=embed) options = useful.getMenuEmoji(5) def roles_emojis_main_menu(reaction, user): return (user == ctx.author) and (str(reaction.emoji) in options) try: reaction, user = await self.bot.wait_for('reaction_add', check=roles_emojis_main_menu, timeout=60.0) except asyncio.TimeoutError: try: await ctx.channel.send(":no_entry: | **" + ctx.author.nick + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") except TypeError: await ctx.channel.send(":no_entry: | **" + ctx.author.name + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") await menu.delete() else: await menu.remove_reaction(reaction.emoji, user) if str(reaction.emoji) == "0\u20e3": await self.roleAdminMenu(ctx, menu, role) elif str(reaction.emoji) == "1\u20e3": await self.roleNSFWMenu(ctx, menu, role) elif str(reaction.emoji) == "2\u20e3": await self.rolePubQuizMenu(ctx, menu, role) elif str(reaction.emoji) == "3\u20e3": await self.roleMiscMenu(ctx, menu, role) elif str(reaction.emoji) == "4\u20e3": await self.rolePresetMenu(ctx, menu, role) elif str(reaction.emoji) == "❌": closed = await ctx.channel.send(":white_check_mark: | Menu closed!") await menu.delete() await asyncio.sleep(1) await closed.delete()
async def rolePubQuizMenuPage2(self, ctx, menu, role): embed = discord.Embed(title='Pub Quiz Permission options (2/2)', description="These commands allow users to create and partake in pub quizzes.\n\nOptions:\n0: settext\n1: correct\n2: leaderboard\n3: Enable all quizmaster commands\n4: Disable all quizmaster commands\n5: Previous page\n6: Back to main menu\nx: Closes Menu", colour=self.bot.getcolour()) embed.set_footer(text="Current role: "+ role.name +"("+ str(role.id)+")") await menu.edit(embed=embed) options = useful.getMenuEmoji(5) def roles_emojis_admin_menu(reaction, user): return (user == ctx.author) and (str(reaction.emoji) in options) try: reaction, user = await self.bot.wait_for('reaction_add', check=roles_emojis_admin_menu, timeout=60.0) except asyncio.TimeoutError: try: await ctx.channel.send(":no_entry: | **" + ctx.author.nick + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") except TypeError: await ctx.channel.send(":no_entry: | **" + ctx.author.name + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") await menu.delete() else: await menu.remove_reaction(reaction.emoji, user) if str(reaction.emoji) == "0\u20e3": permissionToEdit = "pqsettext" await self.roleToggleFunction(ctx, role, menu, permissionToEdit) await self.rolePubQuizMenuPage2(ctx, menu, role) if str(reaction.emoji) == "1\u20e3": permissionToEdit = "pqcorrect" await self.roleToggleFunction(ctx, role, menu, permissionToEdit) await self.rolePubQuizMenuPage2(ctx, menu, role) if str(reaction.emoji) == "2\u20e3": permissionToEdit = "pqleaderboard" await self.roleToggleFunction(ctx, role, menu, permissionToEdit) await self.rolePubQuizMenuPage2(ctx, menu, role) if str(reaction.emoji) == "3\u20e3": toeditTrue = ["pqstart", "pqend", "pqquestion", "pqsuperquestion","pqoverride","pqsettime","pqqmhelp", "pqsettext", "pqcorrect"] toeditFalse = [] await self.editRolePermissions(ctx, menu, role, toeditTrue, toeditFalse) await self.rolePubQuizMenuPage2(ctx, menu, role) elif str(reaction.emoji) == "4\u20e3": toeditTrue = [] toeditFalse = ["pqstart", "pqend", "pqquestion", "pqsuperquestion","pqoverride","pqsettime","pqqmhelp", "pqsettext", "pqcorrect"] await self.editRolePermissions(ctx, menu, role, toeditTrue, toeditFalse) await self.rolePubQuizMenuPage2(ctx, menu, role) elif str(reaction.emoji) == "5\u20e3": await self.rolePubQuizMenu(ctx, menu, role) elif str(reaction.emoji) == "6\u20e3": await self.rolesMainMenu(ctx, menu, role) elif str(reaction.emoji) == "❌": closed = await ctx.channel.send(":white_check_mark: | Menu closed!") await menu.delete() await asyncio.sleep(1) await closed.delete()
async def setupMainMenu(self, ctx, menu): embed = discord.Embed(title='Modules main menu', description="Here you can select which modules are enabled on this server.\n\nOptions:\n0: Administrator\n1: Miscellaneous\n2: Pub Quiz\n3: Bluetext\n4: Welcome\n5: Leave\n6: Games\n7: NSFW\n8: Next Page\nx: Closes Menu", colour=self.bot.getcolour()) embed.set_footer(text="Current guild: "+ ctx.guild.name +"("+ str(ctx.guild.id)+")") await menu.edit(embed=embed) options = useful.getMenuEmoji(9) def emojiCheck(reaction, user): return (user == ctx.author) and (str(reaction.emoji) in options) try: reaction, user = await self.bot.wait_for('reaction_add', check=emojiCheck, timeout=60.0) except asyncio.TimeoutError: try: await ctx.channel.send(":no_entry: | **" + ctx.author.nick + "** The command menu has closed due to inactivity. Please reuse the modules command to restart the process.") except TypeError: await ctx.channel.send(":no_entry: | **" + ctx.author.name + "** The command menu has closed due to inactivity. Please reuse the modules command to restart the process.") await menu.delete() else: await menu.remove_reaction(reaction.emoji, user) if str(reaction.emoji) == "0\u20e3": await self.setupAdminMenu(ctx, menu) elif str(reaction.emoji) == "1\u20e3": await self.setupMiscMenu(ctx, menu) elif str(reaction.emoji) == "2\u20e3": await self.setupPubQuizMenu(ctx, menu) elif str(reaction.emoji) == "3\u20e3": await self.setupBluetextMenu(ctx, menu) elif str(reaction.emoji) == "4\u20e3": await self.setupWelcomeMenu(ctx, menu) elif str(reaction.emoji) == "5\u20e3": await self.setupLeaveMenu(ctx, menu) elif str(reaction.emoji) == "6\u20e3": await self.setupGamesMenu(ctx, menu) elif str(reaction.emoji) == "7\u20e3": await self.setupNSFWMenu(ctx, menu) elif str(reaction.emoji) == "8\u20e3": await self.setupMainMenu(ctx, menu) elif str(reaction.emoji) == "❌": closed = await ctx.channel.send(":white_check_mark: | Menu closed!") await menu.delete() await asyncio.sleep(1) await closed.delete()
async def editrole(self, ctx, *, roleName): role = discord.utils.get(ctx.guild.roles, name=roleName) if role is None: await ctx.channel.send(":no_entry: | Role not found.") else: query = "SELECT * FROM Roles WHERE roleID = $1" result = await ctx.bot.db.fetchrow(query, role.id) if result is None: connection = await self.bot.db.acquire() async with connection.transaction(): query = "INSERT INTO Roles (roleID, guildID) VALUES($1, $2) ON CONFLICT DO NOTHING" await self.bot.db.execute(query, role.id, ctx.guild.id) await self.bot.db.release(connection) embed = discord.Embed(title="Menu Loading...", description="Please stand by.", colour=self.bot.getcolour()) menu = await ctx.channel.send(embed = embed) emojis = useful.getMenuEmoji(10) for emoji in range(0,len(emojis)): await menu.add_reaction(emojis[emoji]) await self.rolesMainMenu(ctx, menu, role)
async def rolePresetMenu(self, ctx, menu, role): embed = discord.Embed(title='Preset Permission options', description="This menu allows you to change this role to a preset permission level.\n\nOptions:\n0: Administrator\n1: Moderator\n2: Default\n3: Quiz Master\n4: Jailed\n5: Back to main menu\nx: Closes Menu", colour=self.bot.getcolour()) embed.set_footer(text="Current role: "+ role.name +"("+ str(role.id)+")") await menu.edit(embed=embed) options = useful.getMenuEmoji(7) def roles_emojis_admin_menu(reaction, user): return (user == ctx.author) and (str(reaction.emoji) in options) try: reaction, user = await self.bot.wait_for('reaction_add', check=roles_emojis_admin_menu, timeout=60.0) except asyncio.TimeoutError: try: await ctx.channel.send(":no_entry: | **" + ctx.author.nick + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") except TypeError: await ctx.channel.send(":no_entry: | **" + ctx.author.name + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") await menu.delete() else: await menu.remove_reaction(reaction.emoji, user) if str(reaction.emoji) == "0\u20e3": await self.rolePresetAdmin(ctx, menu, role) elif str(reaction.emoji) == "1\u20e3": await self.rolePresetModerator(ctx, menu, role) elif str(reaction.emoji) == "4\u20e3": await self.rolePresetJailed(ctx, menu, role) elif str(reaction.emoji) == "2\u20e3": await self.rolePresetDefault(ctx, menu, role) elif str(reaction.emoji) == "3\u20e3": await self.rolePresetQuizMaster(ctx, menu, role) elif str(reaction.emoji) == "5\u20e3": await self.rolesMainMenu(ctx, menu, role) elif str(reaction.emoji) == "❌": closed = await ctx.channel.send(":white_check_mark: | Menu closed!") await menu.delete() await asyncio.sleep(1) await closed.delete()
async def roleMiscMenu(self, ctx, menu, role): embed = discord.Embed(title='Misc Permission options', description="These commands are mostly for fun.\n\nOptions:\n0: bluetext\n1: bluetextcode\n2: cute\n3: conch\n4: eightball\n5:selfassignable\n6: Enable all\n7: Disable all\n8: Back to main menu\nx: Closes Menu", colour=self.bot.getcolour()) embed.set_footer(text="Current role: "+ role.name +"("+ str(role.id)+")") await menu.edit(embed=embed) options = useful.getMenuEmoji(8) def roles_emojis_admin_menu(reaction, user): return (user == ctx.author) and (str(reaction.emoji) in options) try: reaction, user = await self.bot.wait_for('reaction_add', check=roles_emojis_admin_menu, timeout=60.0) except asyncio.TimeoutError: try: await ctx.channel.send(":no_entry: | **" + ctx.author.nick + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") except TypeError: await ctx.channel.send(":no_entry: | **" + ctx.author.name + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") await menu.delete() else: await menu.remove_reaction(reaction.emoji, user) if str(reaction.emoji) == "0\u20e3": permissionToEdit = "bluetext" await self.roleToggleFunction(ctx, role, menu, permissionToEdit) await self.roleMiscMenu(ctx, menu, role) elif str(reaction.emoji) == "1\u20e3": permissionToEdit = "bluetextcode" await self.roleToggleFunction(ctx, role, menu, permissionToEdit) await self.roleMiscMenu(ctx, menu, role) elif str(reaction.emoji) == "2\u20e3": permissionToEdit = "cute" await self.roleToggleFunction(ctx, role, menu, permissionToEdit) await self.roleMiscMenu(ctx, menu, role) elif str(reaction.emoji) == "3\u20e3": permissionToEdit = "conch" await self.roleToggleFunction(ctx, role, menu, permissionToEdit) await self.roleMiscMenu(ctx, menu, role) elif str(reaction.emoji) == "4\u20e3": permissionToEdit = "eightball" await self.roleToggleFunction(ctx, role, menu, permissionToEdit) await self.roleMiscMenu(ctx, menu, role) elif str(reaction.emoji) == "5\u20e3": permissionToEdit = "selfassignable" await self.roleToggleFunction(ctx, role, menu, permissionToEdit) await self.roleMiscMenu(ctx, menu, role) elif str(reaction.emoji) == "6\u20e3": toeditTrue = ["bluetext", "bluetextcode", "eightball", "cute", "conch"] toeditFalse = [] await self.editRolePermissions(ctx, menu, role, toeditTrue, toeditFalse) await self.roleMiscMenu(ctx, menu, role) elif str(reaction.emoji) == "7\u20e3": toeditTrue = [] toeditFalse = ["bluetext", "bluetextcode", "eightball", "cute", "conch"] await self.editRolePermissions(ctx, menu, role, toeditTrue, toeditFalse) await self.roleMiscMenu(ctx, menu, role) elif str(reaction.emoji) == "8\u20e3": await self.rolesMainMenu(ctx, menu, role) elif str(reaction.emoji) == "❌": closed = await ctx.channel.send(":white_check_mark: | Menu closed!") await menu.delete() await asyncio.sleep(1) await closed.delete()
async def roleAdminMenuPage2(self, ctx, menu, role): embed = discord.Embed(title='Administrator Permission options (2/2)', description="These commands allow users to perform a variety of admin tasks.\n\nOptions: \n0: setmuterole\n1: mute\n2: muted (disables all commands)\n3: setkicktext\n4: setbantext\n5: Enable All\n6: Disable All\n7: Previous Page\n8: Back to main menu\nx: Closes Menu", colour=self.bot.getcolour()) embed.set_footer(text="Current role: "+ role.name +"("+ str(role.id)+")") await menu.edit(embed=embed) options = useful.getMenuEmoji(7) def roles_emojis_admin_menu(reaction, user): return (user == ctx.author) and (str(reaction.emoji) in options) try: reaction, user = await self.bot.wait_for('reaction_add', check=roles_emojis_admin_menu, timeout=60.0) except asyncio.TimeoutError: try: await ctx.channel.send(":no_entry: | **" + ctx.author.nick + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") except TypeError: await ctx.channel.send(":no_entry: | **" + ctx.author.name + "** The command menu has closed due to inactivity. Please reuse the editrole command to restart the process.") await menu.delete() else: await menu.remove_reaction(reaction.emoji, user) if str(reaction.emoji) == "0\u20e3": permissionToEdit = "setmuterole" await self.roleToggleFunction(ctx, role, menu,permissionToEdit) await self.roleAdminMenuPage2(ctx, menu, role) elif str(reaction.emoji) == "1\u20e3": permissionToEdit = "mute" await self.roleToggleFunction(ctx, role, menu, permissionToEdit) await self.roleAdminMenuPage2(ctx, menu, role) elif str(reaction.emoji) == "2\u20e3": permissionToEdit = "muted" await self.roleToggleFunction(ctx, role, menu, permissionToEdit) await self.roleAdminMenuPage2(ctx, menu, role) elif str(reaction.emoji) == "3\u20e3": permissionToEdit = "setkicktext" await self.roleToggleFunction(ctx, role, menu, permissionToEdit) await self.roleAdminMenuPage2(ctx, menu, role) elif str(reaction.emoji) == "4\u20e3": permissionToEdit = "setbantext" await self.roleToggleFunction(ctx, role, menu, permissionToEdit) await self.roleAdminMenuPage2(ctx, menu, role) elif str(reaction.emoji) == "5\u20e3": toeditTrue = ["setmuterole", "mute", "editrole", "setwelcomechannel", "setwelcometext", "setleavechannel", "setleavetext", "toggleraid", "setraidrole", "setraidtext", "setkicktext", "setbantext"] toeditFalse = [] await self.editRolePermissions(ctx, menu, role, toeditTrue, toeditFalse) await self.roleAdminMenuPage2(ctx, menu, role) elif str(reaction.emoji) == "6\u20e3": toeditFalse = ["setmuterole", "mute", "editrole", "setwelcomechannel", "setwelcometext", "setleavechannel", "setleavetext", "toggleraid", "setraidrole", "setraidtext", "setbantext", "setkicktext"] toeditTrue = [] await self.editRolePermissions(ctx, menu, role, toeditTrue, toeditFalse) await self.roleAdminMenuPage2(ctx, menu, role) elif str(reaction.emoji) == "7\u20e3": await self.roleAdminMenu(ctx, menu, role) elif str(reaction.emoji) == "8\u20e3": await self.rolesMainMenu(ctx, menu, role) elif str(reaction.emoji) == "❌": closed = await ctx.channel.send(":white_check_mark: | Menu closed!") await menu.delete() await asyncio.sleep(1) await closed.delete()