MCPcopy
hub / github.com/codebymitch/TitanBot / execute

Function execute

src/commands/JoinToCreate/modules/config_setup.js:25–168  ·  view source on GitHub ↗
(interaction, config, client)

Source from the content-addressed store, hash-verified

23
24export default {
25 async execute(interaction, config, client) {
26 try {
27 const triggerChannel = interaction.options.getChannel('trigger_channel');
28 const guildId = interaction.guild.id;
29
30 const currentConfig = await getJoinToCreateConfig(client, guildId);
31
32 if (!currentConfig.triggerChannels.includes(triggerChannel.id)) {
33 throw new TitanBotError(
34 `Channel ${triggerChannel.id} is not a Join to Create trigger`,
35 ErrorTypes.VALIDATION,
36 `${triggerChannel} is not configured as a Join to Create trigger channel.`
37 );
38 }
39
40 const embed = new EmbedBuilder()
41 .setTitle('Join to Create Configuration')
42 .setDescription(`Configure settings for ${triggerChannel}`)
43 .setColor(getColor('info'))
44 .addFields(
45 {
46 name: 'Current Channel Name Template',
47 value: `\`${currentConfig.channelOptions?.[triggerChannel.id]?.nameTemplate || currentConfig.channelNameTemplate}\``,
48 inline: false
49 },
50 {
51 name: 'Current User Limit',
52 value: `${currentConfig.channelOptions?.[triggerChannel.id]?.userLimit || currentConfig.userLimit === 0 ? 'No limit' : currentConfig.userLimit + ' users'}`,
53 inline: true
54 },
55 {
56 name: 'Current Bitrate',
57 value: `${(currentConfig.channelOptions?.[triggerChannel.id]?.bitrate || currentConfig.bitrate) / 1000} kbps`,
58 inline: true
59 }
60 )
61 .setFooter({ text: 'Select an option to configure below' })
62 .setTimestamp();
63
64 const selectMenu = new StringSelectMenuBuilder()
65 .setCustomId(`jointocreate_config_${triggerChannel.id}`)
66 .setPlaceholder('Select a configuration option')
67 .addOptions(
68 new StringSelectMenuOptionBuilder()
69 .setLabel('Change Channel Name Template')
70 .setDescription('Modify the template for temporary channel names')
71 .setValue('name_template'),
72 new StringSelectMenuOptionBuilder()
73 .setLabel('Change User Limit')
74 .setDescription('Set maximum users per temporary channel')
75 .setValue('user_limit'),
76 new StringSelectMenuOptionBuilder()
77 .setLabel('Change Bitrate')
78 .setDescription('Adjust audio quality for temporary channels')
79 .setValue('bitrate'),
80 new StringSelectMenuOptionBuilder()
81 .setLabel('Remove This Trigger Channel')
82 .setDescription('Remove this channel from the Join to Create system')

Callers

nothing calls this directly

Calls 9

getJoinToCreateConfigFunction · 0.90
getColorFunction · 0.90
replyUserErrorFunction · 0.90
handleNameTemplateChangeFunction · 0.85
handleUserLimitChangeFunction · 0.85
handleBitrateChangeFunction · 0.85
handleRemoveTriggerFunction · 0.85
handleViewSettingsFunction · 0.85
safeEditReplyMethod · 0.80

Tested by

no test coverage detected