You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.2 KiB
Rust
39 lines
1.2 KiB
Rust
3 years ago
|
use crate::commands::music::{get_queue_for_guild, is_dj};
|
||
|
use serenity::client::Context;
|
||
|
use serenity::framework::standard::macros::command;
|
||
|
use serenity::framework::standard::{Args, CommandResult};
|
||
|
use serenity::model::channel::Message;
|
||
|
|
||
|
#[command]
|
||
|
#[description("Moves a song in the queue from one position to a new one")]
|
||
|
#[usage("<old-pos> <new-pos>")]
|
||
|
#[example("102 2")]
|
||
|
#[min_args(2)]
|
||
|
#[max_args(2)]
|
||
|
#[bucket("general")]
|
||
|
#[only_in(guilds)]
|
||
|
#[aliases("mvs", "movesong", "move-song")]
|
||
|
async fn move_song(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
|
||
|
let guild = msg.guild(&ctx.cache).await.unwrap();
|
||
|
log::debug!("Moving song for guild {}", guild.id);
|
||
|
|
||
|
let pos1 = args.single::<usize>()?;
|
||
|
let pos2 = args.single::<usize>()?;
|
||
|
|
||
|
if !is_dj(ctx, guild.id, &msg.author).await? {
|
||
|
msg.channel_id.say(ctx, "Requires DJ permissions").await?;
|
||
|
return Ok(());
|
||
|
}
|
||
|
let queue = get_queue_for_guild(ctx, &guild.id).await?;
|
||
|
let mut queue_lock = queue.lock().await;
|
||
|
queue_lock.move_position(pos1, pos2);
|
||
|
msg.channel_id
|
||
|
.say(
|
||
|
ctx,
|
||
|
format!("Moved Song `{}` to new position `{}`", pos1, pos2),
|
||
|
)
|
||
|
.await?;
|
||
|
|
||
|
Ok(())
|
||
|
}
|