Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
message.author.id TypeError: Cannot read properties of undefined (reading 'id')

Why i didnt get message.author.id and create the channel with special permissions?

const {SlashCommandBuilder} = require("@discordjs/builders")
const { Client, Permissions } = require('discord.js');
module.exports = {
    //Create the Command 
    data: new SlashCommandBuilder()
        .setName("veranstaltung")
        .setDescription(`erstelle eine Veranstaltung`)
        .addStringOption(option1=> option1.setName("name").setDescription("Der Name der Veranstaltung").setRequired(true))
        .addStringOption(option2=> option2.setName("datum").setDescription("Das Datum der Veranstaltung").setRequired(true)),
    async execute(message){
        const name = message.options.get("name").value
        const Datum = message.options.get("datum").value
        const userid =


            //Create the Channel with Permissions
            message.guild.channels.create('new-voice', {
                type: 'GUILD_VOICE',
                permissionOverwrites: [
                    {
                        id: message.author.id,
                        deny: [Permissions.FLAGS.VIEW_CHANNEL],
                    },
                ],
            })
            .then(
                message.reply ("Der Kanal " + name + " am " + Datum + " Wurde erfolgreich erstellt")
                )

            }

}

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

It looks like you are using interactions. To access the user object, use Interaction.user, not Interaction.author (this is used in message commands). So, to access the author id, use the following:

message.user.id

Docs: https://discord.js.org/#/docs/discord.js/stable/class/Interaction?scrollTo=user

about 4 years ago · Juan Pablo Isaza Report

0

Slash commands are not message, they are interaction. So you should use your handler as interactionCreate and in your command file you'll edit all things according to interaction. Whenever you want to get id whos used command, you'll use;

interaction.user.id

You can look docs for more info.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!