Fix update to newer version
This commit is contained in:
parent
8ecca44e76
commit
3f6fc4e4e0
5 changed files with 67 additions and 59 deletions
|
@ -9,7 +9,7 @@ typemap = "~0.3"
|
||||||
serde_json = "*"
|
serde_json = "*"
|
||||||
utilities = { git = "http://dimov.cloud/hodasemi/utilities" }
|
utilities = { git = "http://dimov.cloud/hodasemi/utilities" }
|
||||||
rusqlite = { version = "*", features = ["bundled"] }
|
rusqlite = { version = "*", features = ["bundled"] }
|
||||||
serenity = { version = "0.7", default-features = false, features = [ "builder", "cache", "client", "framework", "gateway", "model", "standard_framework", "utils", "voice", "rustls_backend"]}
|
serenity = { version = "0.8", default-features = false, features = [ "builder", "cache", "client", "framework", "gateway", "model", "standard_framework", "utils", "voice", "rustls_backend"]}
|
||||||
parking_lot = "*"
|
parking_lot = "*"
|
||||||
failure = "*"
|
failure = "*"
|
||||||
hey_listen = "*"
|
hey_listen = "*"
|
||||||
|
|
BIN
Penis1
BIN
Penis1
Binary file not shown.
BIN
RUSSIAN VILLAGE BOYS - LOVE NETHERLANDS (MUSIC VIDEO)
Normal file
BIN
RUSSIAN VILLAGE BOYS - LOVE NETHERLANDS (MUSIC VIDEO)
Normal file
Binary file not shown.
45
src/main.rs
45
src/main.rs
|
@ -11,24 +11,16 @@ mod player;
|
||||||
use serenity::{
|
use serenity::{
|
||||||
framework::standard::{
|
framework::standard::{
|
||||||
help_commands,
|
help_commands,
|
||||||
macros::{check, command, group, help},
|
macros::{group, help},
|
||||||
Args, CheckResult, CommandGroup, CommandOptions, CommandResult, DispatchError, HelpOptions,
|
Args, CommandGroup, CommandResult, HelpOptions, StandardFramework,
|
||||||
StandardFramework,
|
|
||||||
},
|
},
|
||||||
model::{
|
model::{channel::Message, id::UserId},
|
||||||
channel::{Channel, Message},
|
|
||||||
gateway::Ready,
|
|
||||||
id::UserId,
|
|
||||||
},
|
|
||||||
utils::{content_safe, ContentSafeOptions},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// This imports `typemap`'s `Key` as `TypeMapKey`.
|
// This imports `typemap`'s `Key` as `TypeMapKey`.
|
||||||
use serenity::prelude::*;
|
use serenity::prelude::*;
|
||||||
|
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::thread;
|
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use player::prelude::*;
|
use player::prelude::*;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
@ -51,11 +43,9 @@ impl Default for Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
group!({
|
#[group]
|
||||||
name: "general",
|
#[commands(ip, list, pause, play, remove, skip, stop)]
|
||||||
options: {},
|
struct General;
|
||||||
commands: [ip, list, pause, play, remove, skip, stop]
|
|
||||||
});
|
|
||||||
|
|
||||||
#[help]
|
#[help]
|
||||||
fn my_help(
|
fn my_help(
|
||||||
|
@ -147,29 +137,6 @@ fn main() -> VerboseResult<()> {
|
||||||
.help(&MY_HELP),
|
.help(&MY_HELP),
|
||||||
);
|
);
|
||||||
|
|
||||||
thread::spawn(move || loop {
|
|
||||||
{
|
|
||||||
let mut media_lock = media_data.lock().unwrap();
|
|
||||||
|
|
||||||
// check if there is a song currently being played
|
|
||||||
let mut is_playing = false;
|
|
||||||
|
|
||||||
if let Some(song) = media_lock.song() {
|
|
||||||
let song_lock = song.lock();
|
|
||||||
|
|
||||||
if !song_lock.finished {
|
|
||||||
is_playing = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !is_playing {
|
|
||||||
MediaData::next_song(&mut media_lock).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
thread::sleep(Duration::from_millis(1500));
|
|
||||||
});
|
|
||||||
|
|
||||||
let _ = client
|
let _ = client
|
||||||
.start()
|
.start()
|
||||||
.map_err(|why| println!("Client ended: {:?}", why));
|
.map_err(|why| println!("Client ended: {:?}", why));
|
||||||
|
|
|
@ -13,6 +13,12 @@ use serenity::{
|
||||||
|
|
||||||
use utilities::prelude::*;
|
use utilities::prelude::*;
|
||||||
|
|
||||||
|
use std::sync::Once;
|
||||||
|
use std::thread;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
static WATCHER: Once = Once::new();
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
fn play(ctx: &mut Context, msg: &Message, mut args: Args) -> CommandResult {
|
fn play(ctx: &mut Context, msg: &Message, mut args: Args) -> CommandResult {
|
||||||
if let Err(err) = channel_contains_author(ctx, msg) {
|
if let Err(err) = channel_contains_author(ctx, msg) {
|
||||||
|
@ -29,31 +35,66 @@ fn play(ctx: &mut Context, msg: &Message, mut args: Args) -> CommandResult {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut media_lock = media.lock().unwrap();
|
{
|
||||||
|
let mut media_lock = media.lock().unwrap();
|
||||||
|
|
||||||
if args.len() == 0 {
|
if args.len() == 0 {
|
||||||
if !check_for_continue(media_lock.song_mut()) {
|
if !check_for_continue(media_lock.song_mut()) {
|
||||||
msg.channel_id
|
msg.channel_id
|
||||||
.say(&ctx.http, "Must provide a URL to a video or audio")?;
|
.say(&ctx.http, "Must provide a URL to a video or audio")?;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let first_arg = args.current().unwrap();
|
|
||||||
|
|
||||||
if first_arg == "--local" {
|
|
||||||
handle_local_request(&mut media_lock, ctx, msg)?;
|
|
||||||
} else if first_arg.starts_with("http") {
|
|
||||||
handle_http_request(&mut media_lock, ctx, msg, first_arg)?;
|
|
||||||
} else {
|
|
||||||
let mut arg_list = args.single::<String>()?;
|
|
||||||
|
|
||||||
for arg in args.iter::<String>() {
|
|
||||||
arg_list += &format!(" {}", arg?.trim());
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
let first_arg = args.current().unwrap();
|
||||||
|
|
||||||
handle_song_request(&mut media_lock, ctx, msg, &arg_list)?
|
if first_arg == "--local" {
|
||||||
|
handle_local_request(&mut media_lock, ctx, msg)?;
|
||||||
|
} else if first_arg.starts_with("http") {
|
||||||
|
handle_http_request(&mut media_lock, ctx, msg, first_arg)?;
|
||||||
|
} else {
|
||||||
|
let mut arg_list = args.single::<String>()?;
|
||||||
|
|
||||||
|
for arg in args.iter::<String>() {
|
||||||
|
arg_list += &format!(" {}", arg?.trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_song_request(&mut media_lock, ctx, msg, &arg_list)?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WATCHER.call_once(|| {
|
||||||
|
let media_data = media.clone();
|
||||||
|
let message_clone = msg.clone();
|
||||||
|
let context_clone = ctx.clone();
|
||||||
|
|
||||||
|
thread::spawn(move || loop {
|
||||||
|
{
|
||||||
|
let mut media_lock = media_data.lock().unwrap();
|
||||||
|
|
||||||
|
// check if there is a song currently being played
|
||||||
|
let mut is_playing = false;
|
||||||
|
|
||||||
|
if let Some(song) = media_lock.song() {
|
||||||
|
let song_lock = song.lock();
|
||||||
|
|
||||||
|
if !song_lock.finished {
|
||||||
|
is_playing = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !is_playing {
|
||||||
|
if let Err(err) =
|
||||||
|
MediaData::next_song(&context_clone, &mut media_lock, &message_clone)
|
||||||
|
{
|
||||||
|
println!("{}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
thread::sleep(Duration::from_millis(1500));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue