Im trying to make a kick
functionality where if AdminRole types /kick
@user it kicks them but if someone in MemberRole tries saying /kick @user
it says back Sorry, you don't have permissions to use this!
client.on("message", (message) =>
{
if (message.content.startsWith("/kick"))
//checking if user is an admin role
if (message.member.roles.find('AdminRole'))
{
var member= message.mentions.members.first();
// Kick
member.kick().then((member) => {
// Successmessage
message.channel.send(":wave: " + member.displayName + " has been successfully kicked :point_right: ");
}).catch(() => {
// Failmessage
message.channel.send("Sorry, command failed");
});
}
if (message.member.roles.find('MemberRole'))
{
message.reply("Sorry, you don't have permissions to use this!");
}
});
Here is the error it spits back out, keep in mind it only spits this error when someone types the /kick
command regardless of role
if (typeof value === 'undefined')
throw new Error('Value must be specified.')
;
^
Error: Value must be specified. at Map.find (/Users/MainUser/Desktop/bot/node_modules/discord.js/src/util/Collection.js:499:45) at Client.client.on (/Users/MainUser/Desktop/bot/index.js:12:34) at Client.emit (events.js:198:13) at MessageCreateHandler.handle (/Users/MainUser/Desktop/bot/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34) at WebSocketPacketManager.handle (/Users/MainUser/Desktop/bot/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65) at WebSocketConnection.onPacket (/Users/MainUser/Desktop/bot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35) at WebSocketConnection.onMessage (/Users/MainUser/Desktop/bot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17) at WebSocket.onMessage (/Users/MainUser/Desktop/bot/node_modules/ws/lib/event-target.js:120:16) at WebSocket.emit (events.js:198:13) at Receiver.receiverOnMessage (/Users/MainUser/Desktop/bot/node_modules/ws/lib/websocket.js:789:20)