if((!tg||!tg.staffrole||!tg.staffrole.length||!message.member.roles.cache.has(tg.staffrole))&&!message.member.permissions.has("ADMINISTRATOR")){returnmessage.channel.send("You don't have the permissions to do that in this server! Ask a server admin to do it for you");}
if(!message.guild.me.permissions.has("MANAGE_ROLES")){returnmessage.channel.send("I don't have permissions to add roles to members in this server, so it would be useless to try and setup any level roles!");}
if(!args[1]){returnmessage.reply("please provide a level and a role to reward for reaching that level!");}
letlevel=args[1];
if(isNaN(Number(level))||Number(level)>200||Number(level)<1){returnmessage.reply("the level must be a positive number lower than 200!");}
if(!args[2]){returnmessage.channel.send("Please try again and provide a role mention or ID of the role you'd like to add after the level!");}
if(!args[2].match(/<@\&\d+>/gm)&&!args[2].match(/\d+/gm)){returnmessage.channel.send("Hmm, it doesn't look like you gave me a role.");}
if(Object.keys(lr.roles).length>=20){returnmessage.channel.send("Due to data storage concerns, you can only have 20 level roles in this server. If you believe you need more, come to the support server and talk to my devs and see if they would be willing to raise this requirement for you.");}
if(!s.length){returnmessage.channel.send("Hmm, there was some kind of error there. It may be that your server's leveling roles were deleted, or there was some internal error when trying to read them. Contact my devs if the problem persists.");}
if(!lr){returnmessage.channel.send("Your server doesn't seem to have any leveling roles set up!");}
if(!args[1]){returnmessage.channel.send("Please provide the level you'd like to remove from the level roles *not the role you want to remove*");}
if(!lr.roles[args[1]]){returnmessage.channel.send("Hmm, it looks like that level doesn't have a role for it. Make sure you provided the *level* and not the *role*.");}
deletelr.roles[args[1]];
lr.markModified(`roles.${args[1]}`);
lr.save();
returnmessage.channel.send("Removed that leveling role!");
if(!message.member.permissions.has("ADMINISTRATOR")){returnmessage.channel.send("Unfortunately, you must be an administrator in this server to clear all the leveling roles.");}
letlr=awaitLR.findOne({gid:message.guild.id});
if(!lr){returnmessage.channel.send("Your server doesn't seem to have any leveling roles set up!");}
letconf=awaitask(message,"Are you sure you want to clear your server's leveling roles? This is irreversible! (Accepts only \"yes\" or \"no\")");if(!conf){return;}
if(conf.toLowerCase()!=="yes"){returnmessage.channel.send("Fear not! Your leveling roles are safe, I will still be giving roles to people when they level up.");}