Skip to content

Commit 3031251

Browse files
authored
added detailed commands information (#17)
Added commands as a detail every time the bot replies. This way we don't need to call `help` and it can be minimized. This resolves #15 It is shown in the following way: --- Enabled `auto-merge` in Pull Request <details><summary> <b>Available commands</b> </summary> - `/merge`: Enables auto-merge for Pull Request - `/merge cancel`: Cancels auto-merge for Pull Request - `/merge help`: Shows this menu For more information see the [documentation](https://github.com/paritytech/auto-merge-bot) </details>
1 parent 1d19925 commit 3031251

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/bot.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ const BOT_COMMAND = "/merge";
99
type Command = "merge" | "cancel" | "help";
1010

1111
const botCommands = `
12-
**Available commands**
13-
1412
- \`/merge\`: Enables auto-merge for Pull Request
1513
- \`/merge cancel\`: Cancels auto-merge for Pull Request
1614
- \`/merge help\`: Shows this menu
1715
1816
For more information see the [documentation](https://github.com/paritytech/auto-merge-bot)
1917
`;
2018

19+
const detailCommands = `
20+
<details><summary> <b>Available commands</b> </summary>
21+
22+
${botCommands}
23+
</details>
24+
`;
25+
2126
export class Bot {
2227
constructor(
2328
private readonly comment: IssueComment,
@@ -91,21 +96,21 @@ export class Bot {
9196
await this.commentsApi.reactToComment(this.comment.id, "+1");
9297
await merger.enableAutoMerge();
9398
await this.commentsApi.comment(
94-
"Enabled `auto-merge` in Pull Request",
99+
"Enabled `auto-merge` in Pull Request\n\n" + detailCommands,
95100
);
96101
break;
97102
// `/merge cancel`
98103
case "cancel":
99104
await this.commentsApi.reactToComment(this.comment.id, "+1");
100105
await merger.disableAutoMerge();
101106
await this.commentsApi.comment(
102-
"Disabled `auto-merge` in Pull Request",
107+
"Disabled `auto-merge` in Pull Request\n\n" + detailCommands,
103108
);
104109
break;
105110
// `/merge help`
106111
case "help":
107112
await this.commentsApi.comment(
108-
"## Auto-Merge-Bot\n" + botCommands,
113+
"## Auto-Merge-Bot\n\n" + "**Available commands**" + botCommands,
109114
true,
110115
);
111116
break;
@@ -115,7 +120,7 @@ export class Bot {
115120
await this.commentsApi.comment(
116121
"## Auto-Merge-Bot\n" +
117122
`Command \`${command}\` not recognized.\n\n` +
118-
botCommands,
123+
detailCommands,
119124
true,
120125
);
121126
}

0 commit comments

Comments
 (0)