From 142237fdd07d1160ed62a8b018f6fa1d81d1de0d Mon Sep 17 00:00:00 2001 From: Nico Jensen Date: Mon, 31 Jan 2022 18:57:07 +0100 Subject: [PATCH] Add Sting option to create channel with own name --- src/commands/createVC.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/commands/createVC.js b/src/commands/createVC.js index 19d905a..ce2d5c0 100644 --- a/src/commands/createVC.js +++ b/src/commands/createVC.js @@ -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 }); } } \ No newline at end of file