generated from Baipyrus/DiscordJS-Template
remove vc from custom vc creation
This commit is contained in:
parent
03fb793b6c
commit
067702ecc6
@ -19,7 +19,7 @@ export const data = new SlashCommandBuilder()
|
||||
.addSubcommand((subcommand) =>
|
||||
subcommand
|
||||
.setName('register')
|
||||
.setDescription('Registers an existing voice channel.')
|
||||
.setDescription('Registers an existing voice channel for custom channel creation.')
|
||||
.addChannelOption((option) =>
|
||||
option
|
||||
.setRequired(true)
|
||||
@ -27,6 +27,18 @@ export const data = new SlashCommandBuilder()
|
||||
.addChannelTypes(ChannelType.GuildVoice)
|
||||
.setDescription('The voice channel to be used.')
|
||||
)
|
||||
)
|
||||
.addSubcommand((subcommand) =>
|
||||
subcommand
|
||||
.setName('remove')
|
||||
.setDescription('Remove a voice channel from custom channel creation.')
|
||||
.addChannelOption((option) =>
|
||||
option
|
||||
.setRequired(true)
|
||||
.setName('channel')
|
||||
.addChannelTypes(ChannelType.GuildVoice)
|
||||
.setDescription('The voice channel to be unregistered.')
|
||||
)
|
||||
);
|
||||
export async function execute(interaction) {
|
||||
const { guild, options } = interaction;
|
||||
@ -60,7 +72,7 @@ export async function execute(interaction) {
|
||||
}
|
||||
case 'register': {
|
||||
// Get channel id from user input
|
||||
const id = options.getChannel('channel');
|
||||
const { id } = options.getChannel('channel');
|
||||
|
||||
// Save channel data
|
||||
step = 'save';
|
||||
@ -73,6 +85,31 @@ export async function execute(interaction) {
|
||||
});
|
||||
break;
|
||||
}
|
||||
case 'remove': {
|
||||
// Get channel id from user input
|
||||
const { id } = options.getChannel('channel');
|
||||
|
||||
// Remove channel from guild
|
||||
step = 'remove';
|
||||
const count = await VoiceChannel.destroy({
|
||||
where: {
|
||||
id,
|
||||
create: true
|
||||
}
|
||||
});
|
||||
|
||||
// Set reply based on result of deletion
|
||||
let response = 'Successfully removed';
|
||||
if (count === 0)
|
||||
response = 'Failed to remove';
|
||||
|
||||
// Reply to acknowledge command
|
||||
await interaction.reply({
|
||||
content: `${response} channel from custom channel creation!`,
|
||||
ephemeral: true
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
Loading…
Reference in New Issue
Block a user