jellyfin-discord-bot/server/helper/messageIdentifiers.ts

21 lines
806 B
TypeScript

import { Message } from "discord.js";
// branded types to differentiate objects of identical Type but different contents
export type VoteEndMessage = Message & { readonly __brand: 'vote' }
export type AnnouncementMessage = Message & { readonly __brand: 'announcement' }
export type VoteMessage = Message & { readonly __brand: 'voteend' }
export type DiscordMessage = VoteMessage | VoteEndMessage | AnnouncementMessage
export function isVoteMessage(msg: Message): msg is VoteMessage {
return msg.cleanContent.includes('[Abstimmung]')
}
export function isInitialAnnouncement(msg: Message): msg is AnnouncementMessage {
return msg.cleanContent.includes("[initial]")
}
export function isVoteEndedMessage(msg: Message): msg is VoteEndMessage {
return msg.cleanContent.includes("[Abstimmung beendet]")
}