-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from jontze/release/v0.2.0-rc.1
Release v0.2.0-rc.1
- Loading branch information
Showing
10 changed files
with
494 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#![cfg(feature = "audio")] | ||
use crate::commands::CadencyCommand; | ||
use crate::error::CadencyError; | ||
use crate::utils; | ||
use serenity::{ | ||
async_trait, | ||
client::Context, | ||
model::application::{ | ||
command::Command, interaction::application_command::ApplicationCommandInteraction, | ||
}, | ||
}; | ||
|
||
pub struct Pause; | ||
|
||
#[async_trait] | ||
impl CadencyCommand for Pause { | ||
async fn register(ctx: &Context) -> Result<Command, serenity::Error> { | ||
Ok( | ||
Command::create_global_application_command(&ctx.http, |command| { | ||
command.name("pause").description("Pause current song") | ||
}) | ||
.await?, | ||
) | ||
} | ||
|
||
async fn execute<'a>( | ||
ctx: &Context, | ||
command: &'a mut ApplicationCommandInteraction, | ||
) -> Result<(), CadencyError> { | ||
debug!("Execute pause command"); | ||
if let Some(guild_id) = command.guild_id { | ||
utils::voice::create_deferred_response(ctx, command).await?; | ||
let manager = utils::voice::get_songbird(ctx).await; | ||
if let Some(call) = manager.get(guild_id) { | ||
let handler = call.lock().await; | ||
if handler.queue().is_empty() { | ||
utils::voice::edit_deferred_response(ctx, command, ":x: **Nothing to pause**") | ||
.await?; | ||
} else { | ||
match handler.queue().pause() { | ||
Ok(_) => { | ||
utils::voice::edit_deferred_response( | ||
ctx, | ||
command, | ||
":pause_button: **Paused**", | ||
) | ||
.await?; | ||
} | ||
Err(err) => { | ||
error!("Failed to pause: {err:?}"); | ||
utils::voice::edit_deferred_response( | ||
ctx, | ||
command, | ||
":x: **Could not pause**", | ||
) | ||
.await?; | ||
} | ||
}; | ||
} | ||
} else { | ||
utils::voice::edit_deferred_response(ctx, command, ":x: **Nothing to pause**") | ||
.await?; | ||
} | ||
} else { | ||
utils::create_response( | ||
ctx, | ||
command, | ||
":x: **This command can only be executed on a server**", | ||
) | ||
.await?; | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#![cfg(feature = "audio")] | ||
use crate::commands::CadencyCommand; | ||
use crate::error::CadencyError; | ||
use crate::utils; | ||
use serenity::{ | ||
async_trait, | ||
client::Context, | ||
model::application::{ | ||
command::Command, interaction::application_command::ApplicationCommandInteraction, | ||
}, | ||
}; | ||
|
||
pub struct Resume; | ||
|
||
#[async_trait] | ||
impl CadencyCommand for Resume { | ||
async fn register(ctx: &Context) -> Result<Command, serenity::Error> { | ||
Ok( | ||
Command::create_global_application_command(&ctx.http, |command| { | ||
command | ||
.name("resume") | ||
.description("Resume current song if paused") | ||
}) | ||
.await?, | ||
) | ||
} | ||
|
||
async fn execute<'a>( | ||
ctx: &Context, | ||
command: &'a mut ApplicationCommandInteraction, | ||
) -> Result<(), CadencyError> { | ||
debug!("Execute skip command"); | ||
if let Some(guild_id) = command.guild_id { | ||
utils::voice::create_deferred_response(ctx, command).await?; | ||
let manager = utils::voice::get_songbird(ctx).await; | ||
if let Some(call) = manager.get(guild_id) { | ||
let handler = call.lock().await; | ||
if handler.queue().is_empty() { | ||
utils::voice::edit_deferred_response(ctx, command, ":x: **Nothing to resume**") | ||
.await?; | ||
} else { | ||
match handler.queue().resume() { | ||
Ok(_) => { | ||
utils::voice::edit_deferred_response( | ||
ctx, | ||
command, | ||
":play_pause: **Resumed**", | ||
) | ||
.await?; | ||
} | ||
Err(err) => { | ||
error!("Failed to resume: {err:?}"); | ||
utils::voice::edit_deferred_response( | ||
ctx, | ||
command, | ||
":x: **Could not resume**", | ||
) | ||
.await?; | ||
} | ||
}; | ||
} | ||
} else { | ||
utils::voice::edit_deferred_response(ctx, command, ":x: **Nothing to resume**") | ||
.await?; | ||
} | ||
} else { | ||
utils::create_response( | ||
ctx, | ||
command, | ||
":x: **This command can only be executed on a server**", | ||
) | ||
.await?; | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#![cfg(feature = "audio")] | ||
use crate::commands::CadencyCommand; | ||
use crate::error::CadencyError; | ||
use crate::utils; | ||
use serenity::{ | ||
async_trait, | ||
client::Context, | ||
model::application::{ | ||
command::Command, interaction::application_command::ApplicationCommandInteraction, | ||
}, | ||
}; | ||
|
||
pub struct Skip; | ||
|
||
#[async_trait] | ||
impl CadencyCommand for Skip { | ||
async fn register(ctx: &Context) -> Result<Command, serenity::Error> { | ||
Ok( | ||
Command::create_global_application_command(&ctx.http, |command| { | ||
command.name("skip").description("Skip current song") | ||
}) | ||
.await?, | ||
) | ||
} | ||
|
||
async fn execute<'a>( | ||
ctx: &Context, | ||
command: &'a mut ApplicationCommandInteraction, | ||
) -> Result<(), CadencyError> { | ||
debug!("Execute skip command"); | ||
if let Some(guild_id) = command.guild_id { | ||
utils::voice::create_deferred_response(ctx, command).await?; | ||
let manager = utils::voice::get_songbird(ctx).await; | ||
if let Some(call) = manager.get(guild_id) { | ||
let handler = call.lock().await; | ||
if handler.queue().is_empty() { | ||
utils::voice::edit_deferred_response(ctx, command, ":x: **Nothing to skip**") | ||
.await?; | ||
} else { | ||
match handler.queue().skip() { | ||
Ok(_) => { | ||
utils::voice::edit_deferred_response( | ||
ctx, | ||
command, | ||
":fast_forward: **Skipped current song**", | ||
) | ||
.await?; | ||
} | ||
Err(err) => { | ||
error!("Failed to skip: {err:?}"); | ||
utils::voice::edit_deferred_response( | ||
ctx, | ||
command, | ||
":x: **Could not skip**", | ||
) | ||
.await?; | ||
} | ||
}; | ||
} | ||
} else { | ||
utils::voice::edit_deferred_response(ctx, command, ":x: **Nothing to skip**") | ||
.await?; | ||
} | ||
} else { | ||
utils::create_response( | ||
ctx, | ||
command, | ||
":x: **This command can only be executed on a server**", | ||
) | ||
.await?; | ||
} | ||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.