Skip to content

Commit

Permalink
add binary release workflow and handle unknown command
Browse files Browse the repository at this point in the history
  • Loading branch information
washbin committed Oct 14, 2022
1 parent 945f2c0 commit 384b586
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/release-binary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release binary in github release

on:
push:
tags:
- "v*.*.*"

env:
PROJECT_NAME: hacksquad-bot

jobs:
build:
name: Build and publish the binary
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
override: true

- name: Build the binary
run: |
cargo build --all --release
strip target/release/${{ env.PROJECT_NAME }}
mkdir publish/
mv target/release/${{ env.PROJECT_NAME }} publish/${{ env.PROJECT_NAME }}_linux_amd64
- name: Release the binary
uses: ncipollo/release-action@v1
with:
artifacts: "publish/*"
token: ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Docker

on:
push:
branches: [ main ]
branches: [main]
workflow_dispatch:

env:
Expand Down
15 changes: 14 additions & 1 deletion src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,20 @@ impl EventHandler for Handler {
"hero" => commands::hero::hero(ctx, command.to_owned()).await,
"randomhero" => commands::hero::random_hero(ctx, command.to_owned()).await,
"info" => commands::info::run(ctx, command.to_owned()).await,
other_commands => println!("Unknown command {}", other_commands),
other_commands => {
if let Err(err) = command
.create_interaction_response(ctx.http, |response| {
response.interaction_response_data(|message| {
message.content("Unknown Command").ephemeral(true)
})
})
.await
{
println!("Error sending unknown command response: {:?}", err);
}

println!("Unknown command {}", other_commands)
}
},
Interaction::MessageComponent(ref component) => match component.message.interaction {
Some(ref message_interaction) => match message_interaction.name.as_str() {
Expand Down

0 comments on commit 384b586

Please sign in to comment.