Fetch announcement channel at server start
This commit is contained in:
@ -5,6 +5,7 @@ import { Emotes } from '../events/guildScheduledEventCreate'
|
||||
import { logger } from '../logger'
|
||||
import { Command } from '../structures/command'
|
||||
import { RunOptions } from '../types/commandTypes'
|
||||
import { client } from '../..'
|
||||
|
||||
export default new Command({
|
||||
name: 'closepoll',
|
||||
@ -29,16 +30,8 @@ export default new Command({
|
||||
export async function closePoll(guild: Guild, requestId: string) {
|
||||
const guildId = guild.id
|
||||
logger.info("stopping poll", { guildId: guildId, requestId })
|
||||
const channels: TextChannel[] = <TextChannel[]>(await guild.channels.fetch())
|
||||
?.filter(channel => channel!.id === config.bot.announcement_channel_id)
|
||||
.map((value, _) => value)
|
||||
|
||||
if(!channels || channels.length != 1) {
|
||||
logger.error(`Could not find announcement channel. Found ${channels}`)
|
||||
return
|
||||
}
|
||||
|
||||
const announcementChannel = channels[0]
|
||||
const announcementChannel: TextChannel = client.getAnnouncementChannelForGuild(guildId)
|
||||
|
||||
const messages: Message<true>[] = (await announcementChannel.messages.fetch()) //todo: fetch only pinned messages
|
||||
.map((value, _) => value)
|
||||
|
Reference in New Issue
Block a user