vckick
tggglhhb opened this issue · 4 comments
hi I have an error when I type on my discord server +vckick here is my code and my error log
`client.on('message', async message => {
if (!message.guild) return;
// if the message content starts with "!ban"
if (message.content.startsWith('+vckick')) {
// Make sure the bot user has permissions to make channels and move members in the guild:
if (!message.guild.me.hasPermission(['MANAGE_CHANNELS', 'MOVE_MEMBERS'])) return message.reply('Missing the required Manage Channels and Move Members permissions.');
// Get the mentioned user/bot and check if they're in a voice channel:
const member = message.mentions.members.first();
if (!member) return message.reply('You need to @mention a user/bot to kick from the voice channel.');
if (!member.voiceChannel) return message.reply('That user/bot isn't in a voice channel.');
// Now we make a temporary voice channel, move the user/bot into the channel, and delete it:
const temp_channel = await message.guild.createChannel(user.id, 'voice', [
{ id: guild.id,
deny: ['VIEW_CHANNEL', 'CONNECT', 'SPEAK'], },
{ id: member.id,
deny: ['VIEW_CHANNEL', 'CONNECT', 'SPEAK'] }
]);
await member.setVoiceChannel(temp_channel);
await temp_channel.delete();
// Finally, pass some user response to show it all worked out:
msg.react('👌');
/* or just "message.reply", etc.. up to you!
}
});
`
the error:
(node:2541) UnhandledPromiseRejectionWarning: ReferenceError: user is not defined
at Client.client.on (/home/runner/index.js:121:56)
at Client.emit (events.js:185:15)
at MessageCreateHandler.handle (/home/runner/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/home/runner/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (/home/runner/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (/home/runner/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
at WebSocket.onMessage (/home/runner/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:180:13)
at Receiver._receiver.onmessage (/home/runner/node_modules/ws/lib/websocket.js:137:47)
at Receiver.dataMessage (/home/runner/node_modules/ws/lib/receiver.js:409:14)
(node:2541) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2541) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
If someone could help me
thanks
Hippolyte
What? You never even defined user based on the code above.
Hmm i forgot to close this issue sry
Hmm user was defined the problem was only that I used '' instead of ""