{"size": 1235, "ext": "js", "max_stars_repo_path": "src/commands/utility/giveRole.js", "max_stars_repo_name": "vAnomali/Rin", "max_stars_repo_stars_event_min_datetime": "2020-09-10T17:20:58.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-12T12:03:40.000Z", "max_issues_repo_path": "src/commands/utility/giveRole.js", "max_issues_repo_name": "vAnomali/Rin", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/commands/utility/giveRole.js", "max_forks_repo_name": "vAnomali/Rin", "max_forks_repo_forks_event_min_datetime": "2020-08-25T12:18:18.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-26T03:18:34.000Z"}
{"max_stars_count": 9, "max_issues_count": null, "max_forks_count": 3, "avg_line_length": 28.0681818182, "max_line_length": 108, "alphanum_fraction": 0.6453441296}
function handleError(message) {
	return message.channel.send('', {
		embed: {
			description: `Please follow the format ${message.client.prefix()}giverole user role.`,
			color: colors.error,
		},
	});
}

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(message);
		}

		if (message.guild.me.roles.highest.position < role.position) {
			return message.channel.send('', {
				embed: {
					description: `I am unable to give the requested role. Please check my position in the role hierarchy.`,
					color: colors.error,
				},
			});
		}

		member.roles.add(role).then(() => {
			message.channel.send('', {
				embed: {
					description: `${member.toString()} has been given the role ${role.toString()}`,
					color: role.color || colors.base,
				},
			});
		});
	},
	description: 'Gives a given user a given role.',
	detailed: 'Gives a given user a given role.',
	examples: (prefix) => `${prefix}giverole @Jihyo#2423 @Cutie`,
	name: 'GiveRole',
	permissions: ['MANAGE_ROLES'],
};
