better error display
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -486,7 +486,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "disconic"
|
name = "disconic"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "disconic"
|
name = "disconic"
|
||||||
description = "Discord bot for interacting with subsonic music libraries"
|
description = "Discord bot for interacting with subsonic music libraries"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
authors = [ "Gabriel Fontes <eu@misterio.me>" ]
|
authors = [ "Gabriel Fontes <eu@misterio.me>" ]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
homepage = "https://misterio.me"
|
homepage = "https://misterio.me"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use sunk::Client as SubsonicClient;
|
|||||||
|
|
||||||
use std::{env, fs, io};
|
use std::{env, fs, io};
|
||||||
|
|
||||||
use crate::discord::{Handler, GENERAL_GROUP};
|
use crate::discord::{Handler, GENERAL_GROUP, after_hook};
|
||||||
|
|
||||||
pub struct Client {
|
pub struct Client {
|
||||||
ss_url: String,
|
ss_url: String,
|
||||||
@@ -50,7 +50,8 @@ impl Client {
|
|||||||
.framework(
|
.framework(
|
||||||
StandardFramework::new()
|
StandardFramework::new()
|
||||||
.configure(|c| c.prefix("~"))
|
.configure(|c| c.prefix("~"))
|
||||||
.group(&GENERAL_GROUP),
|
.group(&GENERAL_GROUP)
|
||||||
|
.after(after_hook)
|
||||||
)
|
)
|
||||||
.type_map_insert::<MusicClient>(ss)
|
.type_map_insert::<MusicClient>(ss)
|
||||||
.register_songbird()
|
.register_songbird()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use serenity::{
|
|||||||
async_trait,
|
async_trait,
|
||||||
client::{Context, EventHandler},
|
client::{Context, EventHandler},
|
||||||
framework::standard::{
|
framework::standard::{
|
||||||
macros::{command, group},
|
macros::{command, group, hook},
|
||||||
Args, CommandResult,
|
Args, CommandResult,
|
||||||
},
|
},
|
||||||
model::channel::Message,
|
model::channel::Message,
|
||||||
@@ -28,6 +28,15 @@ pub struct Handler;
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl EventHandler for Handler {}
|
impl EventHandler for Handler {}
|
||||||
|
|
||||||
|
#[hook]
|
||||||
|
pub async fn after_hook(ctx: &Context, msg: &Message, cmd_name: &str, error: CommandResult) {
|
||||||
|
if let Err(why) = error {
|
||||||
|
let text = format!("Error running {}: {:?}", cmd_name, why);
|
||||||
|
msg.reply(&ctx.http, &text).await.ok();
|
||||||
|
eprintln!("{}", &text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[aliases(s, p, play)]
|
#[aliases(s, p, play)]
|
||||||
/// Play a named song
|
/// Play a named song
|
||||||
|
|||||||
Reference in New Issue
Block a user