Add snarky error messages
This commit is contained in:
parent
ce79f8e44a
commit
8d2e5dec41
1 changed files with 18 additions and 18 deletions
|
@ -21,7 +21,7 @@ pub async fn join(ctx: &Context, command: &ApplicationCommandInteraction) -> Str
|
||||||
let connect_to = match channel_id {
|
let connect_to = match channel_id {
|
||||||
Some(channel) => channel,
|
Some(channel) => channel,
|
||||||
None => {
|
None => {
|
||||||
return "You're not in a voice channel".to_string();
|
return "You're not in a voice channel. How do I know where to go?".to_string();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ pub async fn join(ctx: &Context, command: &ApplicationCommandInteraction) -> Str
|
||||||
|
|
||||||
let _handler = manager.join(guild_id, connect_to).await;
|
let _handler = manager.join(guild_id, connect_to).await;
|
||||||
|
|
||||||
"Joining your channel".to_string()
|
"Joining your channel!".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn leave(ctx: &Context, command: &ApplicationCommandInteraction) -> String {
|
pub async fn leave(ctx: &Context, command: &ApplicationCommandInteraction) -> String {
|
||||||
|
@ -49,9 +49,9 @@ pub async fn leave(ctx: &Context, command: &ApplicationCommandInteraction) -> St
|
||||||
return format!("Failed: {:?}", e);
|
return format!("Failed: {:?}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
"Left voice channel".to_string()
|
"Goodbye!".to_string()
|
||||||
} else {
|
} else {
|
||||||
"I'm not in a voice channel".to_string()
|
"I can't leave if I'm not there to bein with!".to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,12 +68,12 @@ pub async fn play(ctx: &mut Context, command: &ApplicationCommandInteraction) ->
|
||||||
let url = match options {
|
let url = match options {
|
||||||
ApplicationCommandInteractionDataOptionValue::String(url) => url,
|
ApplicationCommandInteractionDataOptionValue::String(url) => url,
|
||||||
_ => {
|
_ => {
|
||||||
return "Must provide a URL to a video or audio".to_string();
|
return "You didn't tell me what to play.".to_string();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if !url.starts_with("http") {
|
if !url.starts_with("http") {
|
||||||
return "Must provide a valid URL".to_string();
|
return "That's not a real URL. I'm onto you.".to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
let guild_id = command.guild_id.unwrap();
|
let guild_id = command.guild_id.unwrap();
|
||||||
|
@ -91,7 +91,7 @@ pub async fn play(ctx: &mut Context, command: &ApplicationCommandInteraction) ->
|
||||||
Err(why) => {
|
Err(why) => {
|
||||||
println!("Err starting source: {:?}", why);
|
println!("Err starting source: {:?}", why);
|
||||||
|
|
||||||
return "Error sourcing ffmpeg".to_string();
|
return "Something went horribly wrong. Go yell at Valter.".to_string();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -100,11 +100,11 @@ pub async fn play(ctx: &mut Context, command: &ApplicationCommandInteraction) ->
|
||||||
let message = {
|
let message = {
|
||||||
if let Some(title) = &source_input.metadata.title {
|
if let Some(title) = &source_input.metadata.title {
|
||||||
let mut msg = MessageBuilder::new();
|
let mut msg = MessageBuilder::new();
|
||||||
msg.push_line("Playing song:");
|
msg.push_line("Playing this:");
|
||||||
msg.push_named_link(title, url);
|
msg.push_named_link(title, url);
|
||||||
msg.build()
|
msg.build()
|
||||||
} else {
|
} else {
|
||||||
"Playing song".to_string()
|
"Playing something, I dunno what.".to_string()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ pub async fn stop(ctx: &Context, command: &ApplicationCommandInteraction) -> Str
|
||||||
|
|
||||||
"Stopping song".to_string()
|
"Stopping song".to_string()
|
||||||
} else {
|
} else {
|
||||||
"Not in a voice channel to play in".to_string()
|
"I'm not even in a channel to begin with. Silly.".to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,12 +158,12 @@ pub async fn set_volume(ctx: &mut Context, command: &ApplicationCommandInteracti
|
||||||
let volume = match options {
|
let volume = match options {
|
||||||
ApplicationCommandInteractionDataOptionValue::Number(volume) => *volume,
|
ApplicationCommandInteractionDataOptionValue::Number(volume) => *volume,
|
||||||
_ => {
|
_ => {
|
||||||
return "Must provide a volume level".to_string();
|
return "You've gotta give me a volume level to set.".to_string();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if !(0.0..=100.0).contains(&volume) {
|
if !(0.0..=100.0).contains(&volume) {
|
||||||
return "Must provide a value between 0 and 100".to_string();
|
return "Volume has to be between 0 and 100.".to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut data = ctx.data.write().await;
|
let mut data = ctx.data.write().await;
|
||||||
|
@ -175,9 +175,9 @@ pub async fn set_volume(ctx: &mut Context, command: &ApplicationCommandInteracti
|
||||||
let current_track = data.get::<CurrentlyPlayingTrack>().unwrap();
|
let current_track = data.get::<CurrentlyPlayingTrack>().unwrap();
|
||||||
if let Some(track) = current_track {
|
if let Some(track) = current_track {
|
||||||
track.set_volume(new_volume).unwrap();
|
track.set_volume(new_volume).unwrap();
|
||||||
format!("Setting volume to {}%", volume)
|
format!("Setting volume to {}%.", volume)
|
||||||
} else {
|
} else {
|
||||||
"No track is currently playing".to_string()
|
"Nothing's currently playing and for some reason, something needs to be playing to set the volume.".to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ pub async fn set_loop(ctx: &mut Context, command: &ApplicationCommandInteraction
|
||||||
let loops = match options {
|
let loops = match options {
|
||||||
ApplicationCommandInteractionDataOptionValue::Boolean(loops) => *loops,
|
ApplicationCommandInteractionDataOptionValue::Boolean(loops) => *loops,
|
||||||
_ => {
|
_ => {
|
||||||
return "Must provide whether or not to loop".to_string();
|
return "Do you want me to loop the song or not? Be specific.".to_string();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -203,13 +203,13 @@ pub async fn set_loop(ctx: &mut Context, command: &ApplicationCommandInteraction
|
||||||
if let Some(track) = current_track {
|
if let Some(track) = current_track {
|
||||||
if loops {
|
if loops {
|
||||||
track.enable_loop().expect("Couldn't enable looping");
|
track.enable_loop().expect("Couldn't enable looping");
|
||||||
return format!("Enabling looping on the current track");
|
return format!("Loopin'!");
|
||||||
} else {
|
} else {
|
||||||
track.disable_loop().expect("Couldn't disable looping");
|
track.disable_loop().expect("Couldn't disable looping");
|
||||||
return format!("Disabling looping on the current track");
|
return format!("This is the last time this track will EVER be played.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
"No track is currently playing".to_string()
|
"I can't loop a song if there is no song to loop.".to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue