MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / handleConfigSubcommand

Function handleConfigSubcommand

src/commands/JoinToCreate/jointocreate.js:227–365  ·  view source on GitHub ↗
(interaction, client)

Source from the content-addressed store, hash-verified

225}
226
227async function handleConfigSubcommand(interaction, client) {
228 try {
229 const triggerChannel = interaction.options.getChannel('trigger_channel');
230 const guildId = interaction.guild.id;
231
232 const currentConfig = await getChannelConfiguration(client, guildId, triggerChannel.id);
233 const channelConfig = currentConfig.channelConfig || {};
234
235 const configEmbed = new EmbedBuilder()
236 .setTitle('Join to Create Configuration')
237 .setDescription(`Configuration for ${triggerChannel}`)
238 .setColor(getColor('info'))
239 .addFields(
240 {
241 name: 'Channel Name Template',
242 value: `\`${channelConfig.nameTemplate || currentConfig.channelNameTemplate || "{username}'s Room"}\``,
243 inline: false
244 },
245 {
246 name: 'User Limit',
247 value: `${(channelConfig.userLimit ?? currentConfig.userLimit ?? 0) === 0 ? 'Unlimited' : (channelConfig.userLimit ?? currentConfig.userLimit ?? 0) + ' users'}`,
248 inline: true
249 },
250 {
251 name: 'Bitrate',
252 value: `${(channelConfig.bitrate ?? currentConfig.bitrate ?? 64000) / 1000} kbps`,
253 inline: true
254 }
255 )
256 .setFooter({ text: 'Use the buttons below to modify settings • Only one trigger channel is supported per guild' })
257 .setTimestamp();
258
259 const nameButton = new ButtonBuilder()
260 .setCustomId(`jtc_config_name_${triggerChannel.id}`)
261 .setLabel('📝 Name Template')
262 .setStyle(ButtonStyle.Primary);
263
264 const limitButton = new ButtonBuilder()
265 .setCustomId(`jtc_config_limit_${triggerChannel.id}`)
266 .setLabel('👥 User Limit')
267 .setStyle(ButtonStyle.Primary);
268
269 const bitrateButton = new ButtonBuilder()
270 .setCustomId(`jtc_config_bitrate_${triggerChannel.id}`)
271 .setLabel('🎵 Bitrate')
272 .setStyle(ButtonStyle.Primary);
273
274 const deleteButton = new ButtonBuilder()
275 .setCustomId(`jtc_config_delete_${triggerChannel.id}`)
276 .setLabel('🗑️ Remove Channel')
277 .setStyle(ButtonStyle.Danger);
278
279 const row = new ActionRowBuilder().addComponents(nameButton, limitButton, bitrateButton, deleteButton);
280
281 await InteractionHelper.safeEditReply(interaction, {
282 embeds: [configEmbed],
283 components: [row]
284 });

Callers 1

executeFunction · 0.85

Calls 9

getChannelConfigurationFunction · 0.90
getColorFunction · 0.90
hasManageGuildPermissionFunction · 0.90
handleNameTemplateModalFunction · 0.85
handleUserLimitModalFunction · 0.85
handleBitrateModalFunction · 0.85
handleChannelDeletionFunction · 0.85
safeEditReplyMethod · 0.80
editMethod · 0.80

Tested by

no test coverage detected