Skip to content

Commit

Permalink
fix(discord): add default button attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
XxLittleCxX committed Jan 25, 2024
1 parent 92c471b commit 87d42d8
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions adapters/discord/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,21 @@ export class DiscordMessageEncoder<C extends Context = Context> extends MessageE
return {
type: ComponentType.BUTTON,
url: attrs.href,
label,
label: label || 'Link',
style: ButtonStyles.LINK,
}
} else if (attrs.type === 'input') {
return {
type: ComponentType.BUTTON,
custom_id: `input${attrs.id}:${attrs.text}`,
label,
custom_id: `input${attrs.id}:${attrs.text ?? ''}`,
label: label || 'Input',
style,
}
} else {
return {
type: ComponentType.BUTTON,
custom_id: attrs.id,
label,
label: label || 'Button',
style,
}
}
Expand Down Expand Up @@ -394,10 +394,13 @@ export class DiscordMessageEncoder<C extends Context = Context> extends MessageE
attrs, children.join(''),
))
} else if (type === 'button-group') {
this.rows.push({
type: ComponentType.ACTION_ROW,
components: [],
})
if (this.rows.length && this.rows[this.rows.length - 1].components.length) {
// eg. two <button-group>
this.rows.push({
type: ComponentType.ACTION_ROW,
components: [],
})
}
await this.render(children)
this.rows.push({
type: ComponentType.ACTION_ROW,
Expand Down

0 comments on commit 87d42d8

Please sign in to comment.