Skip to content

Commit

Permalink
Improve installation process and add README
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffo99 committed Sep 16, 2023
1 parent 5403406 commit db77f86
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 19 deletions.
Binary file added .media/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .media/screenshot-slash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# ![](.media/icon.png) Angy Bot

Music player bot for Discord supporting unusual formats and features, intended for use in the [RYG community](https://www.ryg.one/).

> **Warning**
>
> Very hastily developed with no regards to security or code quality, use it at your own risk!
## Links

*No links available right now.*

## Screenshots

![The bot being summoned, a Plex track being played, and playback being stopped in a Discord chat.](.media/screenshot-slash.png)

## Features

Currently supports playing from:

- local filesystem
- yt-dlp
- local Plex instance

> **Warning**
>
> The bot currently supports only the playback of a single track at a time.
## Commands

The bot registers the following Slash Commands:

- `/summon channel:...` · Makes the bot connect to a channel
- `/play file what:...` · If you are the bot owner, plays the file at the given path.
- `/play ytdl what:...` · Tries to download and play the given string with yt-dlp, falling back to `ytsearch:` if it is not a valid URL.
- `/play plex what:...` · Queries a Plex Media Server for a track name, and plays the first result returned.
- `/stop` · Stops playback of any track.

## Installation

Use the provided Docker image:

- [`ghcr.io/ryghub/angybot`](https://github.com/RYGhub/angybot/pkgs/container/angybot)

The following environment variables must be set to configure the bot:

- `ANGY_TOKEN` · The Discord bot token to use.
- `ANGY_APPID` · The Discord application id to use.
- `ANGY_PLEX_SERVER` · The Plex server to use.
- `ANGY_PLEX_TOKEN` · The Plex token to use.
- `ANGY_PLEX_LIBRARY` · The Plex library to use.
- `ANGY_PLEX_REPLACE_FROM` · The string to remove from the media file path for Plex files.
- `ANGY_PLEX_REPLACE_TO` · The string to add in the media file path for Plex files.
- `ANGY_DEV_GUILD_ID` · The guild id to register Slash Commands in.
- `ANGY_DEV_USER_ID` · The user id allowed to use `/play file`.
19 changes: 17 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::env;
use lazy_static::lazy_static;
use serenity::model::id::{UserId, GuildId};


lazy_static! {
Expand All @@ -25,11 +26,25 @@ lazy_static! {
pub static ref PLEX_LIBRARY: String = env::var("ANGY_PLEX_LIBRARY")
.expect("ANGY_PLEX_LIBRARY to be set");

/// The string to remove from the media file path.
/// The string to remove from the media file path for Plex files.
pub static ref PLEX_REPLACE_FROM: String = env::var("ANGY_PLEX_REPLACE_FROM")
.expect("ANGY_PLEX_REPLACE_FROM to be set");

/// The string to add in the media file path.
/// The string to add in the media file path for Plex files.
pub static ref PLEX_REPLACE_TO: String = env::var("ANGY_PLEX_REPLACE_TO")
.expect("ANGY_PLEX_REPLACE_TO to be set");

/// The guild id to register Slash Commands in.
pub static ref DEV_GUILD_ID: GuildId = env::var("ANGY_DEV_GUILD_ID")
.expect("ANGY_DEV_GUILD_ID to be set")
.parse::<u64>()
.expect("ANGY_DEV_GUILD_ID to be a valid u64")
.into();

/// The user id allowed to use `/play file`.
pub static ref DEV_USER_ID: UserId = env::var("ANGY_DEV_USER_ID")
.expect("ANGY_DEV_USER_ID to be set")
.parse::<u64>()
.expect("ANGY_DEV_USER_ID to be a valid u64")
.into();
}
7 changes: 1 addition & 6 deletions src/handler/commands/play.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::env;
use std::ffi::OsString;
use serenity::prelude::*;
use serenity::model::prelude::*;
Expand Down Expand Up @@ -27,11 +26,7 @@ pub async fn play(ctx: &Context, guild: &GuildId, member: &Member, opts: Options
}
// play file
else if option_optional_string(&opts, "file").is_some() {
let dev_user_id: UserId = env::var("ANGY_DEV_USER_ID")
.map_err(|_| AngyError::Bot("`ANGY_DEV_USER_ID` is not set."))?
.parse::<u64>()
.map_err(|_| AngyError::Bot("`ANGY_DEV_USER_ID` is not a valid ID."))?
.into();
let dev_user_id: UserId = crate::config::DEV_USER_ID.clone();

match member.user.id.eq(&dev_user_id) {
false => Err(AngyError::User("This command can be used only by the bot's owner."))?,
Expand Down
12 changes: 1 addition & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
//! # Angy Bot
//!
//! Music player bot for Discord supporting unusual formats and features, intended primarly for usage in the [RYG community](https://www.ryg.one/).
//!
//! ## Supported players
//!
//! Currently supports playing from:
//! - local filesystem
//! - yt-dlp
//! - local Plex instance

//! Main function of Angy Bot.

mod schema;
mod error;
Expand Down

0 comments on commit db77f86

Please sign in to comment.