announcements #18
@ -130,7 +130,7 @@ export class ExtendedClient extends Client {
|
||||
const textChannel: TextChannel = this.getAnnouncementChannelForGuild(guild.id)
|
||||
this.announcementRoleHandlerTask.set(guild.id, schedule("*/10 * * * * *", async () => {
|
||||
const requestId = uuid()
|
||||
const messages = (await textChannel.messages.fetchPinned()).filter(message => message.cleanContent.includes("[announcement]"))
|
||||
const messages = (await textChannel.messages.fetchPinned()).filter(message => message.cleanContent.includes("[initial]"))
|
||||
|
||||
if (messages.size > 1) {
|
||||
logger.error("More than one pinned announcement Messages found. Unable to know which one people react to. Please fix!", { guildId: guild.id, requestId })
|
||||
@ -138,9 +138,11 @@ export class ExtendedClient extends Client {
|
||||
logger.error("Could not find any pinned announcement messages. Unable to manage roles!", { guildId: guild.id, requestId })
|
||||
kenobi marked this conversation as resolved
|
||||
}
|
||||
|
||||
const message = messages.at(0)!
|
||||
const message = await messages.at(0)!.fetch()
|
||||
kenobi marked this conversation as resolved
Outdated
kenobi
commented
```
const message = await messages.at(0)?.fetch()
if (!message) {
logger.error(`No pinned message found`,{requestId,guildId})
return
}
```
|
||||
//logger.debug(`Message: ${JSON.stringify(message, null, 2)}`, { guildId: guild.id, requestId })
|
||||
|
||||
const reactions = await message.reactions.resolve("🎫")
|
||||
const reactions = message.reactions.resolve("🎫")
|
||||
//logger.debug(`reactions: ${JSON.stringify(reactions, null, 2)}`, { guildId: guild.id, requestId })
|
||||
if (reactions) {
|
||||
manageAnnouncementRoles(message.guild, reactions, requestId)
|
||||
} else {
|
||||
@ -149,6 +151,7 @@ export class ExtendedClient extends Client {
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
public stopAnnouncementRoleBackgroundTask(guild: string | Guild, requestId: string) {
|
||||
kenobi marked this conversation as resolved
Outdated
kenobi
commented
Would it be possible to just use string as type for Would it be possible to just use string as type for `guild` so we don't have to check multiple times if we have a guild object?
|
||||
const guildId: string = guild instanceof Guild ? guild.id : guild
|
||||
const task: ScheduledTask | undefined = guild instanceof Guild ? this.announcementRoleHandlerTask.get(guild.id) : this.announcementRoleHandlerTask.get(guild)
|
||||
|
Loading…
Reference in New Issue
Block a user
Unable to continue, should result in a return.