-
-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathautoPublishMessageCreate.ts
More file actions
33 lines (28 loc) · 833 Bytes
/
autoPublishMessageCreate.ts
File metadata and controls
33 lines (28 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {
MessageCreateListener,
type Client,
type ListenerEventData,
Routes
} from "@buape/carbon"
import { MessageFlags } from "discord-api-types/v10"
const autopublishChannelIds = new Set([
"1457939786659790900",
"1471735751606534236",
"1457893269571633285"
])
export default class AutoPublishMessageCreate extends MessageCreateListener {
async handle(data: ListenerEventData[this["type"]], client: Client) {
const channelId = data.channel_id
if (!channelId || !autopublishChannelIds.has(channelId)) {
return
}
if (data.flags && (data.flags & MessageFlags.Crossposted) === MessageFlags.Crossposted) {
return
}
await client.rest
.post(Routes.channelMessageCrosspost(channelId, data.id), {})
.catch((error) => {
console.error("Failed to auto-publish announcement message:", error)
})
}
}