2023-06-25 01:57:30 +02:00
|
|
|
import { Message } from "discord.js";
|
|
|
|
|
2023-07-05 22:54:43 +02:00
|
|
|
|
|
|
|
// branded types to differentiate objects of identical Type but different contents
|
2023-11-19 18:24:13 +01:00
|
|
|
export type VoteEndMessage = Message & { readonly __brand: 'voteend' }
|
2023-07-05 22:54:43 +02:00
|
|
|
export type AnnouncementMessage = Message & { readonly __brand: 'announcement' }
|
2023-11-19 18:24:13 +01:00
|
|
|
export type VoteMessage = Message & { readonly __brand: 'vote' }
|
2023-07-05 22:54:43 +02:00
|
|
|
|
|
|
|
export type DiscordMessage = VoteMessage | VoteEndMessage | AnnouncementMessage
|
|
|
|
|
2023-11-18 18:26:45 +01:00
|
|
|
export function isVoteMessage(message: Message): message is VoteMessage {
|
|
|
|
return message.cleanContent.includes('[Abstimmung]')
|
2023-06-25 02:20:34 +02:00
|
|
|
}
|
2023-11-18 18:26:45 +01:00
|
|
|
export function isInitialAnnouncement(message: Message): message is AnnouncementMessage {
|
|
|
|
return message.cleanContent.includes("[initial]")
|
2023-06-25 02:20:34 +02:00
|
|
|
}
|
2023-11-18 18:26:45 +01:00
|
|
|
export function isVoteEndedMessage(message: Message): message is VoteEndMessage {
|
|
|
|
return message.cleanContent.includes("[Abstimmung beendet]")
|
2023-06-25 01:57:30 +02:00
|
|
|
}
|
2023-07-05 22:54:43 +02:00
|
|
|
|