minor resilience improvement and formatting
in closepoll.ts was an unsafe arrays usage without checking the bounds
This commit is contained in:
@ -41,7 +41,7 @@ export async function execute(event: GuildScheduledEvent) {
|
||||
sentMessage.react(Emotes[i])
|
||||
}
|
||||
|
||||
if(!task){
|
||||
if (!task) {
|
||||
task = schedule("0 * * * * *", () => checkForPollsToClose(event))
|
||||
}
|
||||
|
||||
@ -61,15 +61,15 @@ async function checkForPollsToClose(event: GuildScheduledEvent): Promise<void> {
|
||||
.filter(event => event.name.toLowerCase().includes("voting offen"))
|
||||
.map((value, _) => value)
|
||||
|
||||
if(!events || events.length <= 0) {
|
||||
if (!events || events.length <= 0) {
|
||||
logger.info("Did not find any events. Cancelling", { guildId: event.guildId, requestId })
|
||||
return
|
||||
} else if(events.length > 1) {
|
||||
} else if (events.length > 1) {
|
||||
logger.error(`More than one event found. Don't know which one is the right one :( Events: ${JSON.stringify(events, null, 2)}`, { guildId: event.guildId, requestId })
|
||||
return
|
||||
}
|
||||
const updatedEvent = events[0] //add two hours because of different timezones in discord api and Date.now()
|
||||
if(!updatedEvent.scheduledStartTimestamp) {
|
||||
if (!updatedEvent.scheduledStartTimestamp) {
|
||||
logger.error("Event does not have a scheduled start time. Cancelling", { guildId: event.guildId, requestId })
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user