(Kick_Members) permission

Can someone add a permission for me (in the given script) that only people with the KickMembers permission can execute?
const { SlashCommandBuilder, GuildMember } = require('discord.js');
const { EmbedBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('kick')
.setDescription('Kick einen Nutzer')
.addUserOption(option =>
option
.setName('target')
.setDescription('Bestimme den Nutzer der gekickt werden soll.')
.setRequired(true))
.addStringOption(option =>
option
.setName('reason')
.setDescription('Gib ein Grund für den Kick an.')
.setRequired(true)),
async execute(interaction) {
await interaction.deferReply();

const targetUser = interaction.options.getUser('nutzer');
const reason = interaction.options.getString('grund');

try {

await interaction.guild.members.kick(targetUser, { reason: reason });
} catch (error) {
return interaction.followUp({ content: 'Fehler beim Kicken des Nutzers.', ephemeral: true });
}

const embedBuilder = new EmbedBuilder()
.setTitle('Kick Log')
.setColor('#05a100')
.setDescription(`**Gekickt:** <@${targetUser}>\n **Grund:** ${reason} \n **Von:** ${interaction.user.tag}`)
.setTimestamp()

const logChannel = interaction.guild.channels.cache.get('1129136681065398442');
if (logChannel) {
logChannel.send({ embeds: [embedBuilder] });
} else {
console.error('Der Channel in dem der Log stattfinden sollte, wurde falsch angegeben oder nicht erkannt.');
}

},
};
const { SlashCommandBuilder, GuildMember } = require('discord.js');
const { EmbedBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('kick')
.setDescription('Kick einen Nutzer')
.addUserOption(option =>
option
.setName('target')
.setDescription('Bestimme den Nutzer der gekickt werden soll.')
.setRequired(true))
.addStringOption(option =>
option
.setName('reason')
.setDescription('Gib ein Grund für den Kick an.')
.setRequired(true)),
async execute(interaction) {
await interaction.deferReply();

const targetUser = interaction.options.getUser('nutzer');
const reason = interaction.options.getString('grund');

try {

await interaction.guild.members.kick(targetUser, { reason: reason });
} catch (error) {
return interaction.followUp({ content: 'Fehler beim Kicken des Nutzers.', ephemeral: true });
}

const embedBuilder = new EmbedBuilder()
.setTitle('Kick Log')
.setColor('#05a100')
.setDescription(`**Gekickt:** <@${targetUser}>\n **Grund:** ${reason} \n **Von:** ${interaction.user.tag}`)
.setTimestamp()

const logChannel = interaction.guild.channels.cache.get('1129136681065398442');
if (logChannel) {
logChannel.send({ embeds: [embedBuilder] });
} else {
console.error('Der Channel in dem der Log stattfinden sollte, wurde falsch angegeben oder nicht erkannt.');
}

},
};
14 Replies
d.js toolkit
d.js toolkit13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
treble/luna
treble/luna13mo ago
No i've told you so many times to learn js do it you are struggling with everything and even just reading the docs would help so learn js first then come back
Jonas
JonasOP13mo ago
Bro, I've tried a lot of methods that don't help. Besides, I have no idea how to do it like you told me. I've written to my friend several times, who has been programming JS for years, and even he doesn't really have a clue
d.js docs
d.js docs13mo ago
property GuildMember#permissions The overall set of permissions for this member, taking only roles and owner status into account
Jonas
JonasOP13mo ago
I'm not having a hard time, I've tried the methods the guide gave me, but there are always errors
Jonas
JonasOP13mo ago
No description
treble/luna
treble/luna13mo ago
thats not valid js i have 0 clue where you get that code from
Jonas
JonasOP13mo ago
FROM THIS
treble/luna
treble/luna13mo ago
no Nowhere in the docs does it tell you to use that <GuildMember>.permissions.has() literally not that difficult?
Harnes
Harnes13mo ago
Or set default member permission to this slash command
Jonas
JonasOP13mo ago
No description
d.js docs
d.js docs13mo ago
Explaining <Class> and Class#method notation: learn more
treble/luna
treble/luna13mo ago
i'm done here learn js
! MYA
! MYA13mo ago
LMFAO tbh ill do the same thing
Want results from more Discord servers?
Add your server