Use the role position as a cutoff for commands. With this logic, any role above the selected role will be allowed to use the command, and anything below will not. Server owner will always have permission
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let guildInfo = await lib.discord.guilds['@0.1.0'].retrieve({
guild_id: `${context.params.event.guild_id}`
});
let roleCutoff = guildInfo.roles.find((role) => role.id === process.env.VERIFIED_ROLE_ID).position;
let rolePositions = guildInfo.roles.filter((role) => {
return context.params.event.member.roles.includes(role.id);
}).map((role) => {
return role.position;
});
let highestRole = Math.max(rolePositions);
if (highestRole >= roleCutoff || guildInfo.owner_id === context.params.event.author.id) {
// PUT YOUR COMMAND LOGIC HERE
} else {
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `You don't have permission to do that!`
});
}