jellyfin-discord-bot/server/helper/messageIdentifiers.ts
kenobi fc64728a78
All checks were successful
Compile the repository / compile (pull_request) Successful in 21s
Run unit tests / test (pull_request) Successful in 13s
msg -> message
2023-11-18 18:26:45 +01:00

21 lines
842 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(message: Message): message is VoteMessage {
return message.cleanContent.includes('[Abstimmung]')
}
export function isInitialAnnouncement(message: Message): message is AnnouncementMessage {
return message.cleanContent.includes("[initial]")
}
export function isVoteEndedMessage(message: Message): message is VoteEndMessage {
return message.cleanContent.includes("[Abstimmung beendet]")
}