module.exports = {
	async run(message, args, colors) {
		let member =
			message.mentions.members.first() || (await message.guild.members.cache.get(args[1]));
		let role = message.mentions.roles.first() || (await message.guild.roles.cache.get(args[2]));

		if (!role || !member) {
			return handleError();
		}

		if (message.guild.me.roles.highest.position < role.position) {
			return message.channel.send('', {
				embed: {
					description: `I am unable to remove the requested role. Please check my position in the role hierarchy.`,
					color: colors.error,
				},
			});
		}
		member.roles.remove(role).then(() => {
			message.channel.send('', {
				embed: {
					description: `${member.toString()} has had the role ${role.toString()} removed.`,
					color: role.color || colors.base,
				},
			});
		});

		function handleError() {
			return message.channel.send('', {
				embed: {
					description: `Please follow the format ${message.client.prefix()}removerole @user @role.`,
					color: colors.error,
				},
			});
		}
	},
	description: 'Removes a role from a user.',
	detailed: 'Removes a given role from a given user.',
	examples: (prefix) => `${prefix}removerole @Jihyo@2423 @Cutie`,
	name: 'RemoveRole',
	permissions: ['MANAGE_ROLES'],
};
