Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit f4eb357

Browse files
committed
fix(report): fix bug that created double report posts
1 parent 1a36c45 commit f4eb357

File tree

3 files changed

+103
-71
lines changed

3 files changed

+103
-71
lines changed

src/Commands/Support/report-app.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ export default {
1111
const target = interaction.targetMessage;
1212

1313
const messageData = getDb().messageData;
14-
const messageInDb = await messageData?.findFirst({ where: { channelAndMessageIds: { some: { messageId: { equals: target.id } } } } });
14+
const messageInDb = await messageData?.findFirst({
15+
where: {
16+
channelAndMessageIds: {
17+
some: { messageId: { equals: target.id } },
18+
},
19+
},
20+
});
1521

1622
// check if args.channel is in connectedList DB
1723
if (!messageInDb) {

src/Scripts/blacklist/user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export = {
5454
inline: true,
5555
},
5656
{
57-
name: 'Duration',
57+
name: 'Expires',
5858
value: expires ? `<t:${Math.round(expires.getTime() / 1000)}:R>` : 'Never.',
5959
inline: true,
6060
},

src/Scripts/support/report.ts

Lines changed: 95 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import logger from '../../Utils/logger';
77
export = {
88
async execute(interaction: ChatInputCommandInteraction) {
99
const reportType = interaction.options.getString('type', true) as 'user' | 'server' | 'bug' | 'other';
10-
const emojis = interaction.client.emotes.normal;
11-
12-
const reportSubmit = new ModalBuilder()
10+
const reportModal = new ModalBuilder()
1311
.setTitle('New Report')
1412
.setCustomId(interaction.id)
1513
.addComponents(
@@ -24,89 +22,119 @@ export = {
2422
),
2523
);
2624

27-
if (reportType === 'bug') {
28-
const bugEmbed = new EmbedBuilder()
29-
.setTitle('Affected Components')
30-
.setDescription('Please choose what component of the bot you are facing issues with.')
31-
.setColor('Random');
25+
const emojis = interaction.client.emotes.normal;
3226

33-
const bugComponent = new ActionRowBuilder<StringSelectMenuBuilder>()
27+
if (reportType === 'bug') {
28+
const bugSelect = new ActionRowBuilder<StringSelectMenuBuilder>()
3429
.addComponents(
3530
new StringSelectMenuBuilder()
3631
.setMaxValues(2)
3732
.setCustomId('component')
3833
.setOptions(
3934
new StringSelectMenuOptionBuilder()
4035
.setLabel('Commands')
41-
.setEmoji(emojis.slash as any)
36+
.setEmoji(emojis.slash)
4237
.setValue('Commands'),
4338
new StringSelectMenuOptionBuilder()
4439
.setLabel('Network')
45-
.setEmoji(emojis.clipart as any)
40+
.setEmoji(emojis.clipart)
4641
.setValue('Network'),
4742
new StringSelectMenuOptionBuilder()
4843
.setLabel('Other (Specify)')
49-
.setEmoji('❓' as any)
44+
.setEmoji('❓')
5045
.setValue('Other'),
5146
),
5247
);
5348

54-
const bugReportChannel = await interaction.client.channels.fetch(constants.channel.bugs).catch(() => null) as ForumChannel | null;
55-
const message = await interaction.reply({ embeds: [bugEmbed], components: [bugComponent] });
56-
const collector = message.createMessageComponentCollector({ componentType: ComponentType.StringSelect, idle: 30_000 });
57-
58-
collector.on('collect', async (i) => {
59-
reportSubmit.setComponents(
60-
new ActionRowBuilder<TextInputBuilder>().addComponents(
61-
new TextInputBuilder()
62-
.setCustomId('summary')
63-
.setLabel('Whats the bug about?')
64-
.setPlaceholder('Frequent interaction failures...')
65-
.setStyle(TextInputStyle.Short)),
66-
new ActionRowBuilder<TextInputBuilder>().addComponents(
67-
new TextInputBuilder()
68-
.setCustomId('description')
69-
.setLabel('Detailed Description (OPTIONAL)')
70-
.setPlaceholder('Please describe the steps to reproduce the issue, include any unexpected behavior.')
71-
.setStyle(TextInputStyle.Paragraph)
72-
.setRequired(false)
73-
.setMinLength(17),
74-
));
75-
await i.showModal(reportSubmit);
76-
77-
i.awaitModalSubmit({ time: 60_000 * 5 })
78-
.then(async (bugModal) => {
79-
if (!bugReportChannel) {
80-
logger.error('Bug report channel not found.');
81-
captureMessage('Bug report channel not found.', { user: { id: interaction.user.id, username: interaction.user.tag }, extra: { command: 'Bug Report' } });
82-
return bugModal.reply({ content: 'An error occured while sending your report.', ephemeral: true });
83-
}
49+
const bugEmbed = new EmbedBuilder()
50+
.setTitle('Affected Components')
51+
.setDescription('Please choose what component of the bot you are facing issues with.')
52+
.setColor('Random');
8453

85-
const summary = bugModal.fields.getTextInputValue('summary');
86-
const description = bugModal.fields.getTextInputValue('description');
87-
const appliedTags = i.values.map((value) => bugReportChannel.availableTags.find((tag) => tag.name.includes(value))?.id || 'error lmao');
54+
const message = await interaction.reply({
55+
embeds: [bugEmbed],
56+
components: [bugSelect],
57+
ephemeral: true,
58+
});
8859

89-
const bugReportEmbed = new EmbedBuilder()
90-
.setColor(colors('invisible'))
91-
.setTitle(summary)
92-
.setDescription(`**Affects:** ${i.values.join(', ')}`)
93-
.setThumbnail(interaction.user.avatarURL({ size: 2048 }) ?? interaction.user.defaultAvatarURL)
94-
.setFooter({ text: `Reported by ${interaction.user.tag} (${interaction.user.id})`, iconURL: interaction.user.avatarURL() || interaction.user.defaultAvatarURL });
60+
// get selected bug type
61+
const typeSelection = await message.awaitMessageComponent({
62+
componentType: ComponentType.StringSelect,
63+
time: 30_000,
64+
}).catch(() => null);
65+
66+
reportModal.setComponents(
67+
new ActionRowBuilder<TextInputBuilder>().addComponents(
68+
new TextInputBuilder()
69+
.setCustomId('summary')
70+
.setLabel('Whats the bug about?')
71+
.setPlaceholder('Frequent interaction failures...')
72+
.setStyle(TextInputStyle.Short)),
73+
new ActionRowBuilder<TextInputBuilder>().addComponents(
74+
new TextInputBuilder()
75+
.setCustomId('description')
76+
.setLabel('Detailed Description (OPTIONAL)')
77+
.setPlaceholder('Please describe the steps to reproduce the issue, include any unexpected behavior.')
78+
.setStyle(TextInputStyle.Paragraph)
79+
.setRequired(false)
80+
.setMinLength(17),
81+
));
9582

96-
if (description) bugReportEmbed.addFields({ name: 'Details', value: description });
83+
// show modal to collect extra information
84+
await typeSelection?.showModal(reportModal);
85+
86+
// get modal input and post it to support server forum
87+
typeSelection?.awaitModalSubmit({
88+
time: 60_000 * 5,
89+
filter: (i) => i.customId === reportModal.data.custom_id,
90+
}).then(async (bugModal) => {
91+
const bugReportChannel = await bugModal.client.channels.fetch(constants.channel.bugs).catch(() => null) as ForumChannel | null;
92+
if (!bugReportChannel) {
93+
logger.error('Bug report channel not found.');
94+
captureMessage('Bug report channel not found.', { user: { id: bugModal.user.id, username: bugModal.user.tag }, extra: { command: 'Bug Report' } });
95+
return bugModal.reply({
96+
content: 'An error occured while sending your report. The developers have been notified!',
97+
ephemeral: true,
98+
});
99+
}
97100

98-
await bugReportChannel.threads.create({ name: summary, message: { embeds: [bugReportEmbed] }, appliedTags });
99-
bugModal.reply({
100-
content: `${emojis.yes} Successfully submitted report. Join the support server to view and/or attach screenshots to it.`,
101-
ephemeral: true,
102-
});
101+
const summary = bugModal.fields.getTextInputValue('summary');
102+
const description = bugModal.fields.getTextInputValue('description');
103+
104+
const bugReportEmbed = new EmbedBuilder()
105+
.setColor(colors('invisible'))
106+
.setTitle(summary)
107+
.setDescription(`**Affects:** ${typeSelection.values.join(', ')}`)
108+
.setThumbnail(interaction.user.avatarURL({ size: 2048 }) ?? interaction.user.defaultAvatarURL)
109+
.setFooter({
110+
text: `Reported by ${interaction.user.tag} (${interaction.user.id})`,
111+
iconURL: interaction.user.avatarURL() || interaction.user.defaultAvatarURL,
103112
});
113+
114+
if (description) bugReportEmbed.addFields({ name: 'Details', value: description });
115+
116+
const appliedTags = typeSelection.values
117+
.map((value) => bugReportChannel.availableTags.find((tag) => tag.name.includes(value))?.id || 'error lmao');
118+
119+
// finally make the post in ic central
120+
await bugReportChannel.threads.create({
121+
name: summary,
122+
message: { embeds: [bugReportEmbed] },
123+
appliedTags,
124+
});
125+
126+
bugModal.reply({
127+
content: `${emojis.yes} Successfully submitted report. Join the </support server:924659341049626636> to view and/or attach screenshots to it.`,
128+
ephemeral: true,
129+
});
130+
}).catch((error) => {
131+
if (!error.message.includes('ending with reason: time')) logger.error(error);
104132
});
105133
return;
106134
}
107135

108136
else if (reportType === 'server' || reportType === 'user') {
109-
reportSubmit.addComponents(
137+
reportModal.addComponents(
110138
new ActionRowBuilder<TextInputBuilder>().addComponents(
111139
new TextInputBuilder()
112140
.setCustomId('id')
@@ -118,12 +146,10 @@ export = {
118146
));
119147
}
120148

121-
await interaction.showModal(reportSubmit);
122-
123-
const reportChannel = await interaction.client.channels.fetch(constants.channel.reports).catch(() => null) as TextChannel | null;
124-
125-
interaction.awaitModalSubmit({ time: 60000 * 5, filter: (i) => i.user.id === interaction.user.id && i.customId === reportSubmit.data.custom_id })
149+
await interaction.showModal(reportModal);
150+
interaction.awaitModalSubmit({ time: 60000 * 5, filter: (i) => i.user.id === interaction.user.id && i.customId === reportModal.data.custom_id })
126151
.then(async modalInteraction => {
152+
const reportChannel = await modalInteraction.client.channels.fetch(constants.channel.reports).catch(() => null) as TextChannel | null;
127153
const reportDescription = modalInteraction.fields.getTextInputValue('description');
128154

129155
switch (reportType) {
@@ -135,8 +161,8 @@ export = {
135161
content: stripIndents`
136162
${emojis.no} I couldn't find a user with that ID.\n\n
137163
**To find a user's ID within the network, please follow these instructions:**
138-
${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.
139-
`,
164+
${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.
165+
`,
140166
ephemeral: true,
141167
});
142168
}
@@ -153,8 +179,8 @@ export = {
153179
}
154180

155181
case 'server': {
156-
const Ids = modalInteraction.fields.getTextInputValue('id');
157-
const reportedServer = await interaction.client.guilds.fetch(Ids).catch(() => null);
182+
const ids = modalInteraction.fields.getTextInputValue('id');
183+
const reportedServer = await interaction.client.guilds.fetch(ids).catch(() => null);
158184
if (!reportedServer) {
159185
return modalInteraction.reply({
160186
content: stripIndents`
@@ -174,8 +200,8 @@ export = {
174200
.setThumbnail(reportedServer.iconURL({ size: 2048 }))
175201
.setFooter({ text: `Reported by ${interaction.user.tag} (${interaction.user.id})`, iconURL: interaction.user.avatarURL() || interaction.user.defaultAvatarURL });
176202
await reportChannel?.send({ embeds: [serverReport] });
177-
}
178203
break;
204+
}
179205
default: {
180206
const otherReport = new EmbedBuilder()
181207
.setColor('Random')
@@ -191,4 +217,4 @@ export = {
191217
}).catch((error) => {if (!error.message.includes('ending with reason: time')) logger.error(error);});
192218

193219
},
194-
};
220+
};

0 commit comments

Comments
 (0)