Add Sting option to create channel with own name

This commit is contained in:
Nico Jensen 2022-01-31 18:57:07 +01:00
parent 86ccca9840
commit 142237fdd0

View File

@ -3,18 +3,30 @@ const {MessageEmbed, Guild} = require('discord.js')
module.exports = {
data: new SlashCommandBuilder()
.setName('vc')
.setDescription('create new voice channel.'),
.setName("vc")
.setDescription("create new voice channel.")
.addStringOption(option =>
option.setName("vcname")
.setDescription("Enter your channel Name.")
.setRequired(false)),
async execute(interaction) {
const newChannelName = `${interaction.member.displayName}'s Channel`
var selectedVCName = interaction.options.getString("vcname")
var newChannelName = `${interaction.member.displayName}'s Channel`
if (selectedVCName) {
newChannelName = selectedVCName
}
interaction.guild.channels.create(`${newChannelName}`, {
type: 'GUILD_VOICE',
parent: '589107550520082591',
parent: process.env.PARENT_CHANNEL_ID,
permissionOverwrites: [{
id: interaction.member.user,
allow: ['MANAGE_CHANNELS']
}]
})
interaction.reply("Your channel is created.\nYou have all the rights to modify the channel.\nThe channel is automatically deleted after the last user has left it.")
var replyMsg = "Your channel is created.\nYou have all the rights to modify the channel.\nThe channel is automatically deleted after the last user has left it.";
await interaction.reply({ content: replyMsg, ephemeral: true });
}
}