Skip to content

Commit 06a163e

Browse files
committed
fix: some hard crash and timing issues
1 parent ecb3ef6 commit 06a163e

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

packages/bot/src/struct/JobManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export class JobManager {
9494
.catch(() => null)) as ThreadChannel | null;
9595

9696
if (channel?.archived) {
97-
await channel.setArchived(false);
97+
await channel.setArchived(false).catch(() => null);
9898
}
9999

100100
const payload: Payload = { op: PayloadOpCode.Done };

packages/bot/src/util/handleStaffThreadMessage.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ export async function handleStaffThreadMessage(
1818
interaction: ChatInputCommandInteraction<'cached'>,
1919
action: HandleStaffThreadMessageAction,
2020
) {
21-
const prisma = container.resolve(PrismaClient);
21+
await interaction.deferReply({ ephemeral: true });
2222

23+
const prisma = container.resolve(PrismaClient);
2324
const thread = await prisma.thread.findFirst({
2425
where: {
2526
channelId: interaction.channelId,
2627
closedById: null,
2728
},
2829
});
2930
if (!thread) {
30-
return interaction.reply(i18next.t('common.errors.no_thread'));
31+
return interaction.editReply(i18next.t('common.errors.no_thread'));
3132
}
3233

3334
let options: Partial<SendStaffThreadMessageOptions> = {
@@ -42,7 +43,7 @@ export async function handleStaffThreadMessage(
4243

4344
const member = await interaction.guild.members.fetch(thread.userId).catch(() => null);
4445
if (!member) {
45-
return interaction.reply(i18next.t('common.errors.no_member', { lng: interaction.locale }));
46+
return interaction.editReply(i18next.t('common.errors.no_member', { lng: interaction.locale }));
4647
}
4748

4849
options.member = member;
@@ -59,7 +60,7 @@ export async function handleStaffThreadMessage(
5960
},
6061
});
6162
if (!threadMessage) {
62-
return interaction.reply(
63+
return interaction.editReply(
6364
i18next.t('common.errors.resource_not_found', {
6465
resource: 'message',
6566
lng: interaction.locale,
@@ -68,13 +69,13 @@ export async function handleStaffThreadMessage(
6869
}
6970

7071
if (threadMessage.staffId !== interaction.user.id) {
71-
return interaction.reply(i18next.t('common.errors.not_own_message', { lng: interaction.locale }));
72+
return interaction.editReply(i18next.t('common.errors.not_own_message', { lng: interaction.locale }));
7273
}
7374

7475
const clearAttachment = interaction.options.getBoolean('clear-attachment');
7576

7677
if (attachment && clearAttachment) {
77-
return interaction.reply(
78+
return interaction.editReply(
7879
i18next.t('common.errors.arg_conflict', {
7980
first: 'attachment',
8081
second: 'clear-attachment',

packages/bot/src/util/sendStaffThreadMessage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export async function sendStaffThreadMessage({
101101
}
102102

103103
if (existing) {
104-
await interaction?.reply({ content: 'Successfully edited your message' });
104+
await interaction?.editReply({ content: 'Successfully edited your message' });
105105
setTimeout(async () => {
106106
try {
107107
await interaction?.deleteReply();
@@ -114,7 +114,7 @@ export async function sendStaffThreadMessage({
114114
}
115115

116116
const guildMessage = await channel.send(options as MessageCreateOptions);
117-
await interaction?.reply({ content: 'Successfully posted your message' });
117+
await interaction?.editReply({ content: 'Successfully posted your message' });
118118
setTimeout(async () => {
119119
try {
120120
await interaction?.deleteReply();

0 commit comments

Comments
 (0)