async def unregister(self, ctx: Context): guild, author = ctx.guild, ctx.author if not can_manage_user(ctx, author): return await ctx.reply( "I don't have a role above you which means I can't manage your roles," " please have someone with permissions move my role up!") remove = [] for role in roles: check = discord.utils.get(guild.roles, name=role) if check in author.roles: remove.append(check) await author.remove_roles(*remove, reason="[ Registration ] User unregistered") await ctx.reply("Done, you may now register again!")
async def predicate(ctx: Context): guild, author = ctx.guild, ctx.author if not guild: raise commands.NoPrivateMessage data = await Register(ctx).data() if not data["enabled"]: ctx.command.reset_cooldown(ctx) await ctx.send_error("Registration is not enabled here!") return False if not data["channel"] or not guild.get_channel(data["channel"]): ctx.command.reset_cooldown(ctx) await ctx.send_error( "Either you don't have a channel set up or I could not find it!" ) return False if not can_manage_user(ctx, author): ctx.command.reset_cooldown(ctx) await ctx.send_error( "I don't have a role above you which means I can't manage your roles," " please have someone with permissions move my role up!") return False roles_found = 0 for role in roles: check = discord.utils.get(guild.roles, name=role) if check in guild.roles: roles_found += 1 if roles_found < len(roles): ctx.command.reset_cooldown(ctx) await ctx.send_error( f"It looks like you haven't set up the roles here, you must have all roles in" f" the server to use this function:\n" f"{await ctx.bot.get_prefix(ctx.message)}setreg roles") return False registered_role = discord.utils.get(guild.roles, name="Registered") if registered_role in author.roles: ctx.command.reset_cooldown(ctx) await ctx.send_error( f"It looks like you've already registered on this server!\n" f"Please run `{await ctx.bot.get_prefix(ctx.message)}unregister`" f" if you wish to re-register.") return False return True