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")
)
}
}
CodePudding user response:
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
CodePudding user response:
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.