Skip to content

Commit

Permalink
fix(GuildTicketManager): force fetch channel before creating permissi…
Browse files Browse the repository at this point in the history
…on overwrites (#569)
  • Loading branch information
guidojw authored Jun 4, 2023
1 parent feba808 commit e6511a5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/managers/guild-ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,17 @@ export default class GuildTicketManager extends DataManager<number, Ticket, Tick
name: channelName,
parent: this.context.ticketsCategory ?? undefined
})
await channel.permissionOverwrites.edit(author, { ViewChannel: true })

// In random occassions on the Twin-Rail server, the permission overwrites
// creation shows up in the audit log but not actually in the channel's
// permissions tab. Force fetch the channel from the API first to make
// sure it was created before creating the permission overwrites.
channel = await this.context.guild.channels.fetch(channel.id, { force: true })
if (channel === null || !channel.isTextBased() || channel.isThread()) {
throw new Error('Could not find channel.')
}

await channel.permissionOverwrites.create(author, { ViewChannel: true })
} catch (err) {
await channel?.delete()
throw err
Expand Down

0 comments on commit e6511a5

Please sign in to comment.