def migrateconfig(): directory = os.path.dirname(os.path.realpath(__file__)) configfile = f"{directory}/config.ini" config = configparser.ConfigParser() config.read(configfile) try: admins = [ int(config.get("server_role", "admin_a")), int(config.get("server_role", "admin_b")), int(config.get("server_role", "admin_c")), ] for admin in admins: if admin != 0: rldb.add_admin(admin) print("\nAdmin migration completed.") config.remove_option("server_role", "admin_a") config.remove_option("server_role", "admin_b") config.remove_option("server_role", "admin_c") config.remove_section("server_role") with open(configfile, "w") as f: config.write(f) return True except configparser.NoSectionError: print("Nothing to migrate in config.ini.") return False
async def add_admin(ctx): try: role = ctx.message.role_mentions[0].id except IndexError: try: role = int(ctx.message.content.split()[1]) except ValueError: await ctx.send("Please mention a valid @Role or role ID.") return except IndexError: await ctx.send("Please mention a @Role or role ID.") return rldb.add_admin(role) await ctx.send("Added the role to my admin list.")
async def add_admin(ctx): try: role = ctx.message.role_mentions[0].id except IndexError: try: role = int(ctx.message.content.split()[1]) except ValueError: await ctx.send("Please mention a valid @Role or role ID.") return except IndexError: await ctx.send("Please mention a @Role or role ID.") return add = rldb.add_admin(role) if isinstance(add, Exception): await system_notification(f"Database error when adding a new admin:\n```\n{add}\n```") return await ctx.send("Added the role to my admin list.")