diff --git a/Cargo.lock b/Cargo.lock index 782329f..9c4c8b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "RythmWorks" +version = "0.1.0" +dependencies = [ + "reqwest", + "semver", + "serde", + "serde_json", + "serenity", + "songbird", + "symphonia", + "tokio", + "yt-dlp", +] + [[package]] name = "adler2" version = "2.0.1" @@ -690,21 +705,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "discord_music" -version = "0.1.0" -dependencies = [ - "reqwest", - "semver", - "serde", - "serde_json", - "serenity", - "songbird", - "symphonia", - "tokio", - "yt-dlp", -] - [[package]] name = "discortp" version = "0.6.0" diff --git a/Cargo.toml b/Cargo.toml index 618f4e9..0edf395 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "discord_music" +name = "RythmWorks" version = "0.1.0" edition = "2024" @@ -13,3 +13,14 @@ songbird = { version = "0.5.0", features = ["builtin-queue", "driver", "serenity symphonia = { version = "0.5.5", features = ["aac", "alac", "isomp4", "mp3"] } tokio = "1.48.0" yt-dlp = "1.4.7" + + +[profile.release] +opt-level = "z" +lto = "fat" +debug = false +codegen-units = 1 +panic = 'abort' +strip = true +debug-assertions = false +overflow-checks = true diff --git a/README.md b/README.md index e69de29..af0366d 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,63 @@ +## Welcome to RhythmWorks +Please use the [getting started](#getting-started) section for instructions on how to create a bot for RhythmWorks +### Getting Started +#### You will need to create a bot in Discord for this to work. This is not an application you can add from Discord's App Store. +1. Go to the [Discord Development Portal](https://discord.com/developers/applications) +2. Click New Application +3. Give it a name +4. Go to the OAuth2 Section + - Check mark the "bot" option under "OAuth2 URL Generator" + - Enable the Following Permissions + - Send Messages + - Read Message History + - Connect + - Speak + - Copy the Generated URL and paste it into your browser + - This will automatically launch discord and allow you to add the bot to your server +5. Go to the "Bot" Section + - Click "Reset Token" and copy it + * **You will need to save this in a secure place. This current version does not have a save functionality and you will have to type it in every time** + - When you start the bot, paste the token into the prompt + +6. Keep the bot running while you want music to play +7. **IMPORTANT - You will need to !stop the currently playing track or wait for the track to finish before you start playing a new song. If you don't, the two tracks will play overtop of each other** +### Commands + +``` +!join +``` +This will join the bot to your current voice channel + +``` +!play https://youtube.com/full-url +``` +This will play the youtube audio from the URL + +``` +!stop +``` +Completely stops the bot +``` +!pause +``` +Pauses the currently playing track +``` +!resume +``` +Resumes the paused track +``` +!leave +``` +The bot will leave the channel + +### Roadmap + +- Add save funtionality for Discord Bot Token + +- User Interface for the admin or whoever the person is who started the bot to have a heads up display and be able to control the bot + + +## License + +[AGPLv3](https://choosealicense.com/licenses/agpl-3.0/) + diff --git a/assets/yt-dlp b/assets/yt-dlp new file mode 100755 index 0000000..20aa949 Binary files /dev/null and b/assets/yt-dlp differ diff --git a/assets/yt-dlp.exe b/assets/yt-dlp.exe new file mode 100644 index 0000000..9b2a392 Binary files /dev/null and b/assets/yt-dlp.exe differ diff --git a/src/main.rs b/src/main.rs index 849c904..fbf6592 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ use songbird::input::HlsRequest; use songbird::input::Input; use songbird::tracks::TrackHandle; use std::collections::HashMap; -use std::env; +use std::io; use std::process::Command; use std::process::Stdio; use std::sync::Arc; @@ -105,7 +105,7 @@ impl EventHandler for Handler { } } }; - let output = Command::new("yt-dlp") + let output = Command::new("./assets/yt-dlp") .args(["-f", "bestaudio", "-g", &url]) .stdout(Stdio::piped()) .output() @@ -160,7 +160,10 @@ async fn main() { This program comes with ABSOLUTELY NO WARRANTY\n This is free software, and you are welcome to redistribute it under certain conditions."); updator::update().await; - let token = env::var("DISCORD_TOKEN").expect("Expected a token in the environment"); + println!("Please paste in your bot token"); + let mut input = String::new(); + io::stdin().read_line(&mut input).expect("Failed to read line"); + let token = input.trim(); let intents = GatewayIntents::GUILD_MESSAGES | GatewayIntents::GUILDS | GatewayIntents::DIRECT_MESSAGES diff --git a/src/modules/downloadyt.rs b/src/modules/downloadyt.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/modules/mod.rs b/src/modules/mod.rs index 0ff1503..34d394b 100644 --- a/src/modules/mod.rs +++ b/src/modules/mod.rs @@ -1,2 +1 @@ pub mod updator; -pub mod downloadyt; \ No newline at end of file diff --git a/src/modules/updator.rs b/src/modules/updator.rs index 00dc0ea..ac293c2 100644 --- a/src/modules/updator.rs +++ b/src/modules/updator.rs @@ -1,3 +1,5 @@ +use std::thread; + use serde::Deserialize; use semver::Version; use reqwest; @@ -12,9 +14,13 @@ pub async fn update() { let latest_version = Version::parse(&release_info.tag_name).unwrap(); let current_version = Version::parse(env!("CARGO_PKG_VERSION")).unwrap(); if latest_version > current_version { - println!("Update Available") + println!("Update Available! Please download the latest version"); + println!("URL: https://git.racooncity.org/brotoskyj/RhythmWorks/releases"); + thread::sleep(std::time::Duration::from_secs(10)); + std::process::exit(1); + } else { - println!("Already on current version"); + } } \ No newline at end of file