diff options
| author | seth <[email protected]> | 2024-04-20 02:31:40 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-04-19 22:31:40 -0400 |
| commit | 3d07413690c551d9f034c93af85ae8da5a495e14 (patch) | |
| tree | 517d2e053ebdeb9a3be0ffce6dec36cbc4ce316e /src/handlers/event/mod.rs | |
| parent | 1b92b254bc64b356f5c59657d2f0acc767bb2964 (diff) | |
spring cleaning (#165)
* treewide: lightly refactor everything
* once_cell -> std::sync
* remove build.rs
we can get our target at runtime
* commands::copypasta: refactor selection
* drop owo_colors
* reactboard: always remove author from count
* commands: better handle behavior outside of guilds
* ci: garnix -> gha
* nix: drop flake-parts & pre-commit-hooks
* nix: fix rust flags in derivation
* add gha badge to readme
* ci: fail when format changes are made
* ci: only run on push to main
* nix: fix nil script
* nix: add libiconv to darwin deps
* ci: disable fail-fast
* nix: fix actionlint & static checks
* ci: add release gates
* nix: fix nil check again
* ci: give release gates unique names
* ci: only build static packages in docker workflow
* nix: move dev outputs to subflake
* fix some typos
* nix: cleanup checks & dev shell
* add editorconfig
Diffstat (limited to 'src/handlers/event/mod.rs')
| -rw-r--r-- | src/handlers/event/mod.rs | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/handlers/event/mod.rs b/src/handlers/event/mod.rs index 9c986e1..cc7d727 100644 --- a/src/handlers/event/mod.rs +++ b/src/handlers/event/mod.rs @@ -1,9 +1,8 @@ -use crate::Data; +use crate::{consts, Data, Error}; -use eyre::{Report, Result}; -use log::info; -use poise::serenity_prelude as serenity; -use poise::FrameworkContext; +use eyre::Result; +use log::{debug, info}; +use poise::serenity_prelude::{self as serenity, CreateBotAuthParameters}; use serenity::FullEvent; mod guild; @@ -11,19 +10,24 @@ mod message; mod pinboard; mod reactboard; -pub async fn handle( - ctx: &serenity::Context, - event: &FullEvent, - framework: FrameworkContext<'_, Data, Report>, - data: &Data, -) -> Result<()> { +pub async fn handle(ctx: &serenity::Context, event: &FullEvent, data: &Data) -> Result<(), Error> { match event { FullEvent::Ready { data_about_bot } => { info!("Logged in as {}!", data_about_bot.user.name); + + if let Ok(invite_link) = CreateBotAuthParameters::new().auto_client_id(ctx).await { + let link = invite_link + .scopes(consts::bot_scopes()) + .permissions(*consts::bot_permissions()) + .build(); + info!("Invite me to your server at {link}"); + } else { + debug!("Not displaying invite_link since we couldn't find our client ID"); + } } FullEvent::Message { new_message } => { - message::handle(ctx, framework, new_message, data).await?; + message::handle(ctx, new_message, data).await?; pinboard::handle(ctx, new_message, data).await?; } @@ -31,8 +35,8 @@ pub async fn handle( reactboard::handle(ctx, add_reaction, data).await?; } - FullEvent::GuildCreate { guild, is_new } => { - guild::handle_create(guild, &is_new.unwrap_or_default(), data).await?; + FullEvent::GuildCreate { guild, is_new: _ } => { + guild::handle_create(guild, data).await?; } FullEvent::GuildDelete { |
