Useful debug info

This commit is contained in:
August 2024-09-30 13:25:48 -04:00
parent b2082c89a4
commit 4f3b6c2aa9
Signed by: shibedrill
GPG Key ID: 5FE0CB25945EFAA2
5 changed files with 66 additions and 20 deletions

38
Cargo.lock generated
View File

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4
[[package]]
name = "addr2line"
@ -109,6 +109,19 @@ dependencies = [
"generic-array",
]
[[package]]
name = "build-time"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1219c19fc29b7bfd74b7968b420aff5bc951cf517800176e795d6b2300dd382"
dependencies = [
"chrono",
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.59",
]
[[package]]
name = "bumpalo"
version = "3.16.0"
@ -1245,6 +1258,25 @@ version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustc_version"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
dependencies = [
"semver",
]
[[package]]
name = "rustc_version_runtime"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dd18cd2bae1820af0b6ad5e54f4a51d0f3fcc53b05f845675074efcc7af071d"
dependencies = [
"rustc_version",
"semver",
]
[[package]]
name = "rustix"
version = "0.38.32"
@ -1490,14 +1522,16 @@ dependencies = [
[[package]]
name = "shibe-bot"
version = "0.2.1"
version = "0.2.2"
dependencies = [
"build-time",
"dotenv",
"log",
"poise",
"pretty_env_logger",
"rand",
"roux",
"rustc_version_runtime",
"serde",
"serde_json",
"tokio",

View File

@ -1,6 +1,6 @@
[package]
name = "shibe-bot"
version = "0.2.1"
version = "0.2.2"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -15,3 +15,5 @@ rand = "0.8.5"
serde = { version = "1.0.198", features = ["serde_derive"] }
serde_json = "1.0.116"
roux = "2.2.12"
rustc_version_runtime = "0.3.0"
build-time = "0.1.3"

View File

@ -1,3 +1,9 @@
# shibe-bot
A discord bot using Rust and Poise. Does nothing useful right now. All code is licensed under the MIT license, see LICENSE.txt for details.
# shibe-bot 0.2.2
## About Shibe Bot
Shibe Bot is a Discord bot written in Rust, using the Poise framework and the Serenity API crate. It has a few command groups right now, but none do anything especially useful. Commands are located at [src/command/](src/command/).
## Licensing
Shibe Bot is available under the MIT license. See [LICENSE.txt](LICENSE.txt) for details.
## Environment
The environment variable `TOKEN` must be set to the application's authentication token for the bot to run properly.
## Contributing
Feel free to make PRs or feature requests. See [TODO.md](TODO.md) for future features.

View File

@ -4,6 +4,8 @@ use rand::Rng;
use crate::Context;
use crate::Error;
use build_time::build_time_local;
const INVITE_LINK: &str = "https://discord.com/oauth2/authorize?client_id=1030701552941412382&permissions=116736&response_type=code&redirect_uri=https%3A%2F%2Fdiscordapp.com%2Foauth2%2Fauthorize%3F%26client_id%3D1030701552941412382%26scope%3Dbot&scope=guilds+bot";
/// Add this bot to your server
@ -38,12 +40,17 @@ pub async fn age(
#[poise::command(slash_command, global_cooldown = 30)]
pub async fn info(ctx: Context<'_>) -> Result<(), Error> {
ctx.say(format!(
"Shibe Bot v{} was created by Shibe Drill (@shibedrill) using Rust and \
Poise.\nWebsite: <https://riverdev.carrd.co>\n\
"Shibe Bot v{} was created by Shibe Drill (@shibedrill) \
using Rust and Poise.\n\
rustc version: {}\n\
Build timestamp: {}\n\
Website: <https://riverdev.carrd.co>\n\
Source code: <https://github.com/shibedrill/shibe-bot>\n\
Poise: <https://docs.rs/poise/latest/poise/>\n\
Rust: <https://www.rust-lang.org/>",
env!("CARGO_PKG_VERSION")
env!("CARGO_PKG_VERSION"),
rustc_version_runtime::version(),
build_time_local!()
))
.await?;
info!("Executed command `info` successfully");

View File

@ -58,19 +58,16 @@ async fn event_handler(
_framework: poise::FrameworkContext<'_, Data, Error>,
data: &Data,
) -> Result<(), Error> {
match event {
FullEvent::ChannelDelete {
if let FullEvent::ChannelDelete {
channel,
messages: _,
} => {
info!("Handling event type: ChannelDelete({})", channel.id);
data.config_manager
.lock()
.await
.channels
.retain(|item| *item != u64::from(channel.id));
}
_ => (),
} = event {
info!("Handling event type: ChannelDelete({})", channel.id);
data.config_manager
.lock()
.await
.channels
.retain(|item| *item != u64::from(channel.id));
}
Ok(())
}