I am creating a Discord music bot using discord.js version 13.6.0 and discord-player but I keep getting this error, here is my code:
const { MessageEmbed, Permissions } = require('discord.js');
module.exports = {
name: 'stop',
aliases: [],
utilisation: '{prefix}stop',
voiceChannel: true,
execute(client, message) {
if (message.member.id.permissions.has(Permissions.FLAGS.KICK_MEMBERS)) {
// Stop the player
};
},
};
The error I get when running that command:
if(message.member.id.permissions.has(Permissions.FLAGS.KICK_MEBERS)){
TypeError: Cannot read properties of undefined (reading 'has')
I don't know why this is happening, please could someone help me?
You are trying to read permissions from the member.id
.
If you take a look at the DiscordJS Documentation for member , and look at the available properties, it has both id
and permissions
.
So, changing your line to message.member.permissions.has(Permissions.FLAGS.KICK_MEBERS)
instead of message.member.id.permissions.has(Permissions.FLAGS.KICK_MEBERS)
should fix this for you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.