Skip to content

Commit

Permalink
feat(help): sort the list of commands
Browse files Browse the repository at this point in the history
Closes #1897.
  • Loading branch information
C0ZEN committed Dec 1, 2022
1 parent ee86a63 commit 83a37ee
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 37 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,38 +136,38 @@ Configure the message containing the new release notes on the given channel.
- `@Sonia !feature noon`
- `@Sonia !F`

#### Help
#### Heartbeat

**Commands:**

- help
- h _(shortcut)_
- heartbeat
- hb _(shortcut)_

Sonia will send you a message containing:

- A list of all the commands available.
- The application [readme](README.md) link.
- Her heartbeat (her ping).

**Example:**

- `@Sonia !help`
- `@Sonia !H`
- `@Sonia !heartbeat`
- `@Sonia !hb`

#### Heartbeat
#### Help

**Commands:**

- heartbeat
- hb _(shortcut)_
- help
- h _(shortcut)_

Sonia will send you a message containing:

- Her heartbeat (her ping).
- A list of all the commands available.
- The application [readme](README.md) link.

**Example:**

- `@Sonia !heartbeat`
- `@Sonia !hb`
- `@Sonia !help`
- `@Sonia !H`

#### Lunch

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,23 @@ describe(`DiscordMessageCommandHelpService`, (): void => {
} as EmbedFieldData);
});

it(`should return a Discord message response embed with a help field`, async (): Promise<void> => {
it(`should return a Discord message response embed with a heartbeat field`, async (): Promise<void> => {
expect.assertions(1);

const result = await service.getMessageResponse();

expect(result.options.embeds?.[0]?.fields?.[3]).toStrictEqual({
name: `Heartbeat (*heartbeat* or *hb*)`,
value: `Display my current heartbeat.`,
} as EmbedFieldData);
});

it(`should return a Discord message response embed with a help field`, async (): Promise<void> => {
expect.assertions(1);

const result = await service.getMessageResponse();

expect(result.options.embeds?.[0]?.fields?.[4]).toStrictEqual({
name: `Help (*help* or *h*)`,
value: `Ask for my help, it is obvious! And maybe I will, who knows?`,
} as EmbedFieldData);
Expand All @@ -482,7 +493,7 @@ describe(`DiscordMessageCommandHelpService`, (): void => {

const result = await service.getMessageResponse();

expect(result.options.embeds?.[0]?.fields?.[4]).toStrictEqual({
expect(result.options.embeds?.[0]?.fields?.[5]).toStrictEqual({
name: `Lunch (*lunch* or *l*)`,
value: `There is a time to eat.`,
} as EmbedFieldData);
Expand All @@ -493,7 +504,7 @@ describe(`DiscordMessageCommandHelpService`, (): void => {

const result = await service.getMessageResponse();

expect(result.options.embeds?.[0]?.fields?.[5]).toStrictEqual({
expect(result.options.embeds?.[0]?.fields?.[6]).toStrictEqual({
name: `Quote (*quote* or *q*)`,
value: `I quote others only in order to better express myself.`,
} as EmbedFieldData);
Expand All @@ -504,7 +515,7 @@ describe(`DiscordMessageCommandHelpService`, (): void => {

const result = await service.getMessageResponse();

expect(result.options.embeds?.[0]?.fields?.[6]).toStrictEqual({
expect(result.options.embeds?.[0]?.fields?.[7]).toStrictEqual({
name: `Release notes (*release-notes* or *r*)`,
value: `Display the last version release notes.`,
} as EmbedFieldData);
Expand All @@ -515,23 +526,12 @@ describe(`DiscordMessageCommandHelpService`, (): void => {

const result = await service.getMessageResponse();

expect(result.options.embeds?.[0]?.fields?.[7]).toStrictEqual({
expect(result.options.embeds?.[0]?.fields?.[8]).toStrictEqual({
name: `Version (*version* or *v*)`,
value: `Display my current application version.`,
} as EmbedFieldData);
});

it(`should return a Discord message response embed with a heartbeat field`, async (): Promise<void> => {
expect.assertions(1);

const result = await service.getMessageResponse();

expect(result.options.embeds?.[0]?.fields?.[8]).toStrictEqual({
name: `Heartbeat (*heartbeat* or *hb*)`,
value: `Display my current heartbeat.`,
} as EmbedFieldData);
});

it(`should return a Discord message response embed with a more help field`, async (): Promise<void> => {
expect.assertions(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,17 @@ export class DiscordMessageCommandHelpService extends DiscordMessageCommandCoreS
}

private _getMessageEmbedFields(): EmbedFieldData[] {
// Sort the fields by alphabetical order of the commands!
return [
this._getMessageEmbedFieldCookie(),
this._getMessageEmbedFieldError(),
this._getMessageEmbedFieldFeature(),
this._getMessageEmbedFieldHeartbeat(),
this._getMessageEmbedFieldHelp(),
this._getMessageEmbedFieldLunch(),
this._getMessageEmbedFieldQuote(),
this._getMessageEmbedFieldReleaseNotes(),
this._getMessageEmbedFieldVersion(),
this._getMessageEmbedFieldHeartbeat(),
this._getMessageEmbedFieldMoreHelp(),
];
}
Expand All @@ -106,6 +107,13 @@ export class DiscordMessageCommandHelpService extends DiscordMessageCommandCoreS
};
}

private _getMessageEmbedFieldHeartbeat(): EmbedFieldData {
return {
name: `Heartbeat (*heartbeat* or *hb*)`,
value: `Display my current heartbeat.`,
};
}

private _getMessageEmbedFieldHelp(): EmbedFieldData {
return {
name: `Help (*help* or *h*)`,
Expand Down Expand Up @@ -141,13 +149,6 @@ export class DiscordMessageCommandHelpService extends DiscordMessageCommandCoreS
};
}

private _getMessageEmbedFieldHeartbeat(): EmbedFieldData {
return {
name: `Heartbeat (*heartbeat* or *hb*)`,
value: `Display my current heartbeat.`,
};
}

private _getMessageEmbedFieldMoreHelp(): EmbedFieldData {
return {
name: `Further help`,
Expand Down

0 comments on commit 83a37ee

Please sign in to comment.