move preparation of vote Message sending into vote controller
event only needs to supply information, text creation, sending and pinning happens in the vote controller
This commit is contained in:
		@@ -5,7 +5,7 @@ import { getMembersWithRoleFromGuild } from "./roleFilter"
 | 
			
		||||
import { config } from "../configuration"
 | 
			
		||||
import { VoteMessage, isVoteEndedMessage, isVoteMessage } from "./messageIdentifiers"
 | 
			
		||||
import { createDateStringFromEvent } from "./dateHelper"
 | 
			
		||||
import { Maybe } from "../interfaces"
 | 
			
		||||
import { Maybe, voteMessageInputInformation as prepareVoteMessageInput } from "../interfaces"
 | 
			
		||||
import format from "date-fns/format"
 | 
			
		||||
import toDate from "date-fns/toDate"
 | 
			
		||||
import differenceInDays from "date-fns/differenceInDays"
 | 
			
		||||
@@ -161,6 +161,14 @@ export default class VoteController {
 | 
			
		||||
		throw Error(`Could not find eventId in Vote Message`)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public async prepareAndSendVoteMessage(inputInfo: prepareVoteMessageInput, guildId: string, requestId: string) {
 | 
			
		||||
		const messageText = this.createVoteMessageText(inputInfo.event.id, inputInfo.startDate, inputInfo.movies, guildId, requestId)
 | 
			
		||||
		const sentMessage = await this.sendVoteMessage(messageText, inputInfo.movies.length, inputInfo.announcementChannel)
 | 
			
		||||
		if (inputInfo.pinAfterSending)
 | 
			
		||||
			sentMessage.pin()
 | 
			
		||||
		return sentMessage
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public createVoteMessageText(eventId: string, eventStartDate: Date, movies: string[], guildId: string, requestId: string): string {
 | 
			
		||||
		let message = `[Abstimmung] für https://discord.com/events/${guildId}/${eventId} \n<@&${config.bot.announcement_role}> Es gibt eine neue Abstimmung für die nächste Watchparty ${createDateStringFromEvent(eventStartDate, guildId, requestId)}! Stimme hierunter für den nächsten Film ab!\n`
 | 
			
		||||
 | 
			
		||||
@@ -171,6 +179,7 @@ export default class VoteController {
 | 
			
		||||
 | 
			
		||||
		return message
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public async sendVoteMessage(message: string, movieCount: number, announcementChannel: TextChannel) {
 | 
			
		||||
 | 
			
		||||
		const options: MessageCreateOptions = {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user