diff --git a/src/Commands/Support/report-app.ts b/src/Commands/Support/report-app.ts index 4b631dbd..02b0a0b2 100644 --- a/src/Commands/Support/report-app.ts +++ b/src/Commands/Support/report-app.ts @@ -11,7 +11,13 @@ export default { const target = interaction.targetMessage; const messageData = getDb().messageData; - const messageInDb = await messageData?.findFirst({ where: { channelAndMessageIds: { some: { messageId: { equals: target.id } } } } }); + const messageInDb = await messageData?.findFirst({ + where: { + channelAndMessageIds: { + some: { messageId: { equals: target.id } }, + }, + }, + }); // check if args.channel is in connectedList DB if (!messageInDb) { diff --git a/src/Scripts/blacklist/user.ts b/src/Scripts/blacklist/user.ts index 455cdfa1..3cc19f71 100644 --- a/src/Scripts/blacklist/user.ts +++ b/src/Scripts/blacklist/user.ts @@ -54,7 +54,7 @@ export = { inline: true, }, { - name: 'Duration', + name: 'Expires', value: expires ? `` : 'Never.', inline: true, }, diff --git a/src/Scripts/support/report.ts b/src/Scripts/support/report.ts index c59228dd..5d00ece9 100644 --- a/src/Scripts/support/report.ts +++ b/src/Scripts/support/report.ts @@ -7,9 +7,7 @@ import logger from '../../Utils/logger'; export = { async execute(interaction: ChatInputCommandInteraction) { const reportType = interaction.options.getString('type', true) as 'user' | 'server' | 'bug' | 'other'; - const emojis = interaction.client.emotes.normal; - - const reportSubmit = new ModalBuilder() + const reportModal = new ModalBuilder() .setTitle('New Report') .setCustomId(interaction.id) .addComponents( @@ -24,13 +22,10 @@ export = { ), ); - if (reportType === 'bug') { - const bugEmbed = new EmbedBuilder() - .setTitle('Affected Components') - .setDescription('Please choose what component of the bot you are facing issues with.') - .setColor('Random'); + const emojis = interaction.client.emotes.normal; - const bugComponent = new ActionRowBuilder() + if (reportType === 'bug') { + const bugSelect = new ActionRowBuilder() .addComponents( new StringSelectMenuBuilder() .setMaxValues(2) @@ -38,75 +33,108 @@ export = { .setOptions( new StringSelectMenuOptionBuilder() .setLabel('Commands') - .setEmoji(emojis.slash as any) + .setEmoji(emojis.slash) .setValue('Commands'), new StringSelectMenuOptionBuilder() .setLabel('Network') - .setEmoji(emojis.clipart as any) + .setEmoji(emojis.clipart) .setValue('Network'), new StringSelectMenuOptionBuilder() .setLabel('Other (Specify)') - .setEmoji('❓' as any) + .setEmoji('❓') .setValue('Other'), ), ); - const bugReportChannel = await interaction.client.channels.fetch(constants.channel.bugs).catch(() => null) as ForumChannel | null; - const message = await interaction.reply({ embeds: [bugEmbed], components: [bugComponent] }); - const collector = message.createMessageComponentCollector({ componentType: ComponentType.StringSelect, idle: 30_000 }); - - collector.on('collect', async (i) => { - reportSubmit.setComponents( - new ActionRowBuilder().addComponents( - new TextInputBuilder() - .setCustomId('summary') - .setLabel('Whats the bug about?') - .setPlaceholder('Frequent interaction failures...') - .setStyle(TextInputStyle.Short)), - new ActionRowBuilder().addComponents( - new TextInputBuilder() - .setCustomId('description') - .setLabel('Detailed Description (OPTIONAL)') - .setPlaceholder('Please describe the steps to reproduce the issue, include any unexpected behavior.') - .setStyle(TextInputStyle.Paragraph) - .setRequired(false) - .setMinLength(17), - )); - await i.showModal(reportSubmit); - - i.awaitModalSubmit({ time: 60_000 * 5 }) - .then(async (bugModal) => { - if (!bugReportChannel) { - logger.error('Bug report channel not found.'); - captureMessage('Bug report channel not found.', { user: { id: interaction.user.id, username: interaction.user.tag }, extra: { command: 'Bug Report' } }); - return bugModal.reply({ content: 'An error occured while sending your report.', ephemeral: true }); - } + const bugEmbed = new EmbedBuilder() + .setTitle('Affected Components') + .setDescription('Please choose what component of the bot you are facing issues with.') + .setColor('Random'); - const summary = bugModal.fields.getTextInputValue('summary'); - const description = bugModal.fields.getTextInputValue('description'); - const appliedTags = i.values.map((value) => bugReportChannel.availableTags.find((tag) => tag.name.includes(value))?.id || 'error lmao'); + const message = await interaction.reply({ + embeds: [bugEmbed], + components: [bugSelect], + ephemeral: true, + }); - const bugReportEmbed = new EmbedBuilder() - .setColor(colors('invisible')) - .setTitle(summary) - .setDescription(`**Affects:** ${i.values.join(', ')}`) - .setThumbnail(interaction.user.avatarURL({ size: 2048 }) ?? interaction.user.defaultAvatarURL) - .setFooter({ text: `Reported by ${interaction.user.tag} (${interaction.user.id})`, iconURL: interaction.user.avatarURL() || interaction.user.defaultAvatarURL }); + // get selected bug type + const typeSelection = await message.awaitMessageComponent({ + componentType: ComponentType.StringSelect, + time: 30_000, + }).catch(() => null); + + reportModal.setComponents( + new ActionRowBuilder().addComponents( + new TextInputBuilder() + .setCustomId('summary') + .setLabel('Whats the bug about?') + .setPlaceholder('Frequent interaction failures...') + .setStyle(TextInputStyle.Short)), + new ActionRowBuilder().addComponents( + new TextInputBuilder() + .setCustomId('description') + .setLabel('Detailed Description (OPTIONAL)') + .setPlaceholder('Please describe the steps to reproduce the issue, include any unexpected behavior.') + .setStyle(TextInputStyle.Paragraph) + .setRequired(false) + .setMinLength(17), + )); - if (description) bugReportEmbed.addFields({ name: 'Details', value: description }); + // show modal to collect extra information + await typeSelection?.showModal(reportModal); + + // get modal input and post it to support server forum + typeSelection?.awaitModalSubmit({ + time: 60_000 * 5, + filter: (i) => i.customId === reportModal.data.custom_id, + }).then(async (bugModal) => { + const bugReportChannel = await bugModal.client.channels.fetch(constants.channel.bugs).catch(() => null) as ForumChannel | null; + if (!bugReportChannel) { + logger.error('Bug report channel not found.'); + captureMessage('Bug report channel not found.', { user: { id: bugModal.user.id, username: bugModal.user.tag }, extra: { command: 'Bug Report' } }); + return bugModal.reply({ + content: 'An error occured while sending your report. The developers have been notified!', + ephemeral: true, + }); + } - await bugReportChannel.threads.create({ name: summary, message: { embeds: [bugReportEmbed] }, appliedTags }); - bugModal.reply({ - content: `${emojis.yes} Successfully submitted report. Join the support server to view and/or attach screenshots to it.`, - ephemeral: true, - }); + const summary = bugModal.fields.getTextInputValue('summary'); + const description = bugModal.fields.getTextInputValue('description'); + + const bugReportEmbed = new EmbedBuilder() + .setColor(colors('invisible')) + .setTitle(summary) + .setDescription(`**Affects:** ${typeSelection.values.join(', ')}`) + .setThumbnail(interaction.user.avatarURL({ size: 2048 }) ?? interaction.user.defaultAvatarURL) + .setFooter({ + text: `Reported by ${interaction.user.tag} (${interaction.user.id})`, + iconURL: interaction.user.avatarURL() || interaction.user.defaultAvatarURL, }); + + if (description) bugReportEmbed.addFields({ name: 'Details', value: description }); + + const appliedTags = typeSelection.values + .map((value) => bugReportChannel.availableTags.find((tag) => tag.name.includes(value))?.id || 'error lmao'); + + // finally make the post in ic central + await bugReportChannel.threads.create({ + name: summary, + message: { embeds: [bugReportEmbed] }, + appliedTags, + }); + + bugModal.reply({ + content: `${emojis.yes} Successfully submitted report. Join the to view and/or attach screenshots to it.`, + ephemeral: true, + }); + }).catch((error) => { + if (!error.message.includes('ending with reason: time')) logger.error(error); }); return; } else if (reportType === 'server' || reportType === 'user') { - reportSubmit.addComponents( + reportModal.addComponents( new ActionRowBuilder().addComponents( new TextInputBuilder() .setCustomId('id') @@ -118,12 +146,10 @@ export = { )); } - await interaction.showModal(reportSubmit); - - const reportChannel = await interaction.client.channels.fetch(constants.channel.reports).catch(() => null) as TextChannel | null; - - interaction.awaitModalSubmit({ time: 60000 * 5, filter: (i) => i.user.id === interaction.user.id && i.customId === reportSubmit.data.custom_id }) + await interaction.showModal(reportModal); + interaction.awaitModalSubmit({ time: 60000 * 5, filter: (i) => i.user.id === interaction.user.id && i.customId === reportModal.data.custom_id }) .then(async modalInteraction => { + const reportChannel = await modalInteraction.client.channels.fetch(constants.channel.reports).catch(() => null) as TextChannel | null; const reportDescription = modalInteraction.fields.getTextInputValue('description'); switch (reportType) { @@ -135,8 +161,8 @@ export = { content: stripIndents` ${emojis.no} I couldn't find a user with that ID.\n\n **To find a user's ID within the network, please follow these instructions:** - ${emojis.dotYellow} Right click on a message sent from the user in question select \`Apps > User Info\` or you can get it from the [embed author](https://i.imgur.com/AbTTlry.gif). Please double-check the ID and try again. - `, + ${emojis.dotYellow} Right click on a message sent from the user in question select \`Apps > User Info\`. Please double-check the ID and try again. + `, ephemeral: true, }); } @@ -153,8 +179,8 @@ export = { } case 'server': { - const Ids = modalInteraction.fields.getTextInputValue('id'); - const reportedServer = await interaction.client.guilds.fetch(Ids).catch(() => null); + const ids = modalInteraction.fields.getTextInputValue('id'); + const reportedServer = await interaction.client.guilds.fetch(ids).catch(() => null); if (!reportedServer) { return modalInteraction.reply({ content: stripIndents` @@ -174,8 +200,8 @@ export = { .setThumbnail(reportedServer.iconURL({ size: 2048 })) .setFooter({ text: `Reported by ${interaction.user.tag} (${interaction.user.id})`, iconURL: interaction.user.avatarURL() || interaction.user.defaultAvatarURL }); await reportChannel?.send({ embeds: [serverReport] }); - } break; + } default: { const otherReport = new EmbedBuilder() .setColor('Random') @@ -191,4 +217,4 @@ export = { }).catch((error) => {if (!error.message.includes('ending with reason: time')) logger.error(error);}); }, -}; \ No newline at end of file +};