only admin can run this command discord.js code example

Example 1: permissions discord.js

if (member.hasPermission('KICK_MEMBERS')) {
	console.log('This member can kick');
}

if (member.hasPermission(['KICK_MEMBERS', 'BAN_MEMBERS'])) {
	console.log('This member can kick and ban');
}

if (member.hasPermission('KICK_MEMBERS', { checkAdmin: false, checkOwner: false })) {
	console.log('This member can kick without allowing admin to override');
}

Example 2: discord.js v12 how to set owner commands

// First we use guild.members.fetch to make sure all members are cached
<message>.guild.members.fetch().then(fetchedMembers => {
	const totalOnline = fetchedMembers.filter(member => member.presence.status === 'online');
	// We now have a collection with all online member objects in the totalOnline variable
	<message>.channel.send(`There are currently ${totalOnline.size} members online in this guild!`);
});