Skip to content

Commit

Permalink
GH-433: Empty embeds if game board does not use them
Browse files Browse the repository at this point in the history
  • Loading branch information
utarwyn committed Feb 15, 2023
1 parent db9b5c2 commit f7c1582
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/__tests__/GameBoardBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ describe('GameBoardBuilder', () => {
expect(builder.toMessageOptions()).toEqual({
allowedMentions: { parse: ['users'] },
content: '',
components: []
components: [],
embeds: []
});
});

Expand Down Expand Up @@ -88,7 +89,7 @@ describe('GameBoardBuilder', () => {
it('should set state based if game has expired', () => {
builder.withExpireMessage();
expect(builder.toMessageOptions()).toEqual(
expect.objectContaining({ content: 'game.expire', embeds: undefined })
expect.objectContaining({ content: 'game.expire', embeds: [] })
);
});

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/GameBoardButtonBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('GameBoardButtonBuilder', () => {
});

it('should send empty message by default', () => {
expect(builder.toMessageOptions()).toEqual({ content: '', components: [] });
expect(builder.toMessageOptions()).toEqual({ content: '', components: [], embeds: [] });
});

it('should compute board components', () => {
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('GameBoardButtonBuilder', () => {
${{ toString: () => 'fake' }} | ${'fake, select your move:'}
`('should set state based if playing entity is $entity', ({ entity, state }) => {
builder.withEntityPlaying(entity);
expect(builder.toMessageOptions()).toEqual({ content: state, components: [] });
expect(builder.toMessageOptions()).toEqual({ content: state, components: [], embeds: [] });
});

it('should compute board using disabled buttons after been used', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/bot/builder/GameBoardBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export default class GameBoardBuilder {
allowedMentions: { parse: ['users'] },
embeds: this.embedColor
? [{ title: this.title, description: board + state, color: this.embedColor }]
: undefined,
: [],
content: !this.embedColor ? this.title + board + state : undefined,
components: []
};
Expand Down
2 changes: 1 addition & 1 deletion src/bot/builder/GameBoardButtonBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class GameBoardButtonBuilder extends GameBoardBuilder {
return {
embeds: this.embedColor
? [{ title: this.title, description: this.state, color: this.embedColor }]
: undefined,
: [],
content: !this.embedColor ? this.title + this.state : undefined,
components: [...Array(this.boardSize).keys()].map(row =>
new MessageActionRow().addComponents(
Expand Down

0 comments on commit f7c1582

Please sign in to comment.