#Missing Permissions

1 messages · Page 1 of 1 (latest)

sweet notch
#

Thread

reef wren
#

So member: 828701236911144971

sweet notch
#

yes sir

dense bear
#

828701236911144971 Thats your own id

#

Are you sure youre not the owner of that guild?

frigid surge
#

kiter beat me to it

dense bear
#

Im speed brutha

#

xd

#

log the guild.ownerId @sweet notch

reef wren
#

I'll be damned, trying to ban yourself 🤣

dense bear
#

Either you mistook interaction.member for the member you are trying to kick or somewhere else in the code its getting mixed up

sweet notch
#

because that returns undefined

dense bear
#

yes

dense bear
#

ownerId

#

not id

reef wren
#

owner__I__d

sweet notch
#
const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedMe } = require('../util/embed.js');
const Discord = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('kick')
        .setDescription('Kick\'s a user from the guild.')
        .addMentionableOption(option => option.setName('user').setDescription('The user you wish to kick.').setRequired(true))
        .addStringOption(option => option.setName('reason').setDescription('The reason for the kick.')),
    async execute(interaction) {

        console.log(interaction.guild.ownerId)

        const user = interaction.options.getMentionable('user')
        const member = interaction.guild.members.cache.get(user);
        var reason = interaction.options.getString('reason')

        if(!reason) {
            reason = 'No reason provided.'
        }

        if (!user) {
            const error = EmbedMe('error', interaction)
                .setTitle('Error')
                .setDescription('You must mention a user to kick.');
            return interaction.reply({
                ephemeral: true,
                embeds: [error]
            });
        }

        try {
            await interaction.member.kick();
        } catch (err) {
            console.log(err);
        }

        const reasonEmbed = EmbedMe('main', interaction)
            .setTitle('**Kicked**')
            .setDescription(`You have been kicked from ${interaction.guild.name}\n**Reason**: ${reason}`);
        try {
            await user.send({
                ephemeral: true,
                embeds: [reasonEmbed]
            });
        } catch (err) {
            console.log(err);
        }

        const embed = EmbedMe('main', interaction)
            .setTitle('**Kicked**')
            .setDescription(`${user} has been kicked from the guild.\n**Reason**: ${reason}`)
            .setThumbnail(interaction.user.avatarURL({
                dynamic: true
            }))
            .setTimestamp()
        await interaction.reply({
            ephemeral: true,
            embeds: [embed]
        })
    }
}
#

here's my code

#

btw

frigid surge
#

so to answer a question kiter asked, the guild you're doing this in, is it your own guild that you created?

dense bear
#

Dude

#

interaction.member.kick

#

its literally right there..

reef wren
#

interaction.member.kick - I assume kicking yourself as the command user

sweet notch
#

I did member.kick without interaction before

#

and it didn't work\

#

do i even have to cache or fetch the user?

dense bear
#

interaction.member is the member that emitted the interaction

frigid surge
#

well you're getting the option wrong

#

thats why

dense bear
reef wren
#

Well because member wouldn't be defined on its own

dense bear
#

It goes over this

sweet notch
#
        const user = interaction.options.getMentionable('user')
        const member = interaction.guild.members.cache.get(user);
frigid surge
#

interaction.options.getMember('user')

sweet notch
#

oh it's getMember?

dense bear
dense bear
reef wren
#

Members <> Users

#

Fucking hell I wish everyone knew the difference 🤣

frigid surge
#

yeah, yours technically should work but theres a method specifically for getting a member option

dense bear
frigid surge
#

it also avoids the risk of mentioning a user or a role etc

#

oh I agree, thats why I said technically haha

dense bear
#

getmember is an amazing way to do this

frigid surge
#

I think what confuses people is because there is no member option type, only user

sweet notch
frigid surge
#

change the option type to ApplicationCommandOptionType.User

dense bear
unborn sundialBOT
#

Tag suggestion for @sweet notch:
Despite sounding similar there is a distinct difference between users and members in Discord:
• User: global Discord user data (global avatar, username, tag, id)
• GuildMember: user data associated to a guild (guild, nickname, roles, voice, guild avatar, etc.)
• Conversion: User ➞ GuildMember | GuildMember ➞ User

sweet notch
#

I'm so confused on what i'm changing

frigid surge
sweet notch
#

LMAO

#

I'm still somewhat new to coding so

frigid surge
#

in your options where you create the command. like name description etc, you have an option you called 'user'

#

change the type from a mentionable type

sweet notch
#

ye

frigid surge
#

to a user type

frigid surge
dense bear
#

But

#

Why dont you follow the guide

frigid surge
#

thats my spoonfeeding for the day

dense bear
#

If you are new especially

sweet notch
dense bear
#

Kid we are the reason you get to figure out you cant do basic programming

#

Tell me to chill lol

sweet notch
#

I'm slow, sludge is doing an amazing job at making it simpler for me

dense bear
#

Goodbye

sweet notch
#

so shush

#

mwah

reef wren
#

The guide is simple, whst you seem to be needing is hand holding...which is against rule 5 🤨

sweet notch
#

SleepTime I ask for things to be simplified

reef wren
#

Translation: hand holding.

The guide is simple, if you think it can be simpler, put in a PR

sweet notch
#

LMAO alright bud, whatever you say

#

@frigid surge thanks for the help g

reef wren
#

Or they did

sweet notch
#

At least they helped instead of crying about rules bb_smirk

reef wren
#

I did help.
I asked for the error stack
That's what allowed Kiter to find the problem