Skip to content

Commit 22c3351

Browse files
2 parents 5065a3b + 07a489e commit 22c3351

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/controllers/discord/threads/createDiscordThread.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { DiscordThreadResponse } from "../../../models/DiscordThreadResponse";
22

3-
export default async function createDiscordThread(token: string, channelId: string, messageId: string, name: string) {
3+
export default async function createDiscordThread(token: string, channelId: string, messageId: string, name: string, inactivity: 60 | 1440 | 4320 | 10080) {
44
const response = await fetch(`https://discord.com/api/v9/channels/${channelId}/messages/${messageId}/threads`, {
55
method: "POST",
66
headers: {
77
"Content-Type": "application/json",
88
"Authorization": `Bot ${token}`
99
},
1010
body: JSON.stringify({
11-
name
11+
name,
12+
auto_archive_duration: inactivity
1213
})
1314
});
1415

src/routes/errors/create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default async function handleCreateErrorRequest(request: RequestWithKey,
8181

8282
console.log({ message });
8383

84-
const thread = await createDiscordThread(env.DISCORD_BOT_CLIENT_TOKEN, message.channel_id, message.id, `Alarm ${alarm.id}`);
84+
const thread = await createDiscordThread(env.DISCORD_BOT_CLIENT_TOKEN, message.channel_id, message.id, `Alarm ${alarm.id}`, 60);
8585

8686
console.log({ thread });
8787

0 commit comments

Comments
 (0)