Skip to content

Commit 384b586

Browse files
committed
add binary release workflow and handle unknown command
1 parent 945f2c0 commit 384b586

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

.github/workflows/release-binary.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release binary in github release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
env:
9+
PROJECT_NAME: hacksquad-bot
10+
11+
jobs:
12+
build:
13+
name: Build and publish the binary
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
19+
- name: Install latest rust toolchain
20+
uses: actions-rs/toolchain@v1
21+
with:
22+
toolchain: stable
23+
default: true
24+
override: true
25+
26+
- name: Build the binary
27+
run: |
28+
cargo build --all --release
29+
strip target/release/${{ env.PROJECT_NAME }}
30+
mkdir publish/
31+
mv target/release/${{ env.PROJECT_NAME }} publish/${{ env.PROJECT_NAME }}_linux_amd64
32+
33+
- name: Release the binary
34+
uses: ncipollo/release-action@v1
35+
with:
36+
artifacts: "publish/*"
37+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/docker.yml renamed to .github/workflows/release-docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Docker
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
workflow_dispatch:
77

88
env:

src/events.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,20 @@ impl EventHandler for Handler {
2020
"hero" => commands::hero::hero(ctx, command.to_owned()).await,
2121
"randomhero" => commands::hero::random_hero(ctx, command.to_owned()).await,
2222
"info" => commands::info::run(ctx, command.to_owned()).await,
23-
other_commands => println!("Unknown command {}", other_commands),
23+
other_commands => {
24+
if let Err(err) = command
25+
.create_interaction_response(ctx.http, |response| {
26+
response.interaction_response_data(|message| {
27+
message.content("Unknown Command").ephemeral(true)
28+
})
29+
})
30+
.await
31+
{
32+
println!("Error sending unknown command response: {:?}", err);
33+
}
34+
35+
println!("Unknown command {}", other_commands)
36+
}
2437
},
2538
Interaction::MessageComponent(ref component) => match component.message.interaction {
2639
Some(ref message_interaction) => match message_interaction.name.as_str() {

0 commit comments

Comments
 (0)