Skip to content

Commit

Permalink
⚒️ Use this.data if setData is used
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashu11-A committed Jun 15, 2024
1 parent 9e3bd41 commit 404beb8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plugins/tickets/src/class/TemplateBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class TemplateBuilder {
this.options.color = data.embed.color
this.options.image = data.embed.image?.url
this.options.thumbnail = data.embed.thumbnail?.url
this.data = data
return this
}

Expand All @@ -73,7 +74,7 @@ export class TemplateBuilder {

async edit ({ messageId }: { messageId: string }) {
const buttonBuilder = new TemplateButtonBuilder()
const templateData = await database.findOne({ where: { messageId } })
const templateData = this.data !== undefined ? this.data : await database.findOne({ where: { messageId } })
if (templateData === null) { throw await new Error({ element: 'o template', interaction: this.interaction }).notFound({ type: 'Database' }).reply(); return }

const channel = await this.interaction.guild?.channels.fetch(templateData.channelId)
Expand Down Expand Up @@ -120,7 +121,8 @@ export class TemplateBuilder {

templateData.embed = embed.toJSON()
await database.save(templateData)
await message.edit({ embeds: [embed], components })
if (this.mode !== undefined) { await message.edit({ embeds: [embed], components }); return }
await message.edit({ embeds: [embed] })
}

async delete ({ messageId }: { messageId: string }) {
Expand Down

0 comments on commit 404beb8

Please sign in to comment.