Initial v2.2.0 push
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "spoticord_config"
|
||||
version = "2.2.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
lazy_static = "1.5.0"
|
||||
rspotify = { version = "0.13.2", default-features = false, features = [
|
||||
"client-reqwest",
|
||||
"reqwest-rustls-tls",
|
||||
] }
|
||||
serenity = "0.12.2"
|
||||
@@ -0,0 +1,3 @@
|
||||
# Spoticord: Configuration
|
||||
|
||||
This module contains configuration items for spoticord, like environment variables.
|
||||
@@ -0,0 +1,14 @@
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref DISCORD_TOKEN: String =
|
||||
std::env::var("DISCORD_TOKEN").expect("missing DISCORD_TOKEN environment variable");
|
||||
pub static ref DATABASE_URL: String =
|
||||
std::env::var("DATABASE_URL").expect("missing DATABASE_URL environment variable");
|
||||
pub static ref LINK_URL: String =
|
||||
std::env::var("LINK_URL").expect("missing LINK_URL environment variable");
|
||||
pub static ref SPOTIFY_CLIENT_ID: String =
|
||||
std::env::var("SPOTIFY_CLIENT_ID").expect("missing SPOTIFY_CLIENT_ID environment variable");
|
||||
pub static ref SPOTIFY_CLIENT_SECRET: String = std::env::var("SPOTIFY_CLIENT_SECRET")
|
||||
.expect("missing SPOTIFY_CLIENT_SECRET environment variable");
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
mod env;
|
||||
|
||||
use rspotify::{AuthCodeSpotify, Config, Credentials, OAuth, Token};
|
||||
use serenity::all::GatewayIntents;
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), "-dev");
|
||||
|
||||
/// The "listening to" message that shows up under the Spoticord bot user
|
||||
pub const MOTD: &str = "some good 'ol music";
|
||||
|
||||
/// The time it takes (in seconds) for Spoticord to disconnect when no music is being played
|
||||
pub const DISCONNECT_TIME: u64 = 5 * 60;
|
||||
|
||||
pub fn discord_token() -> &'static str {
|
||||
&env::DISCORD_TOKEN
|
||||
}
|
||||
|
||||
pub fn discord_intents() -> GatewayIntents {
|
||||
GatewayIntents::GUILDS | GatewayIntents::GUILD_VOICE_STATES
|
||||
}
|
||||
|
||||
pub fn database_url() -> &'static str {
|
||||
&env::DATABASE_URL
|
||||
}
|
||||
|
||||
pub fn link_url() -> &'static str {
|
||||
&env::LINK_URL
|
||||
}
|
||||
|
||||
pub fn get_spotify(token: Token) -> AuthCodeSpotify {
|
||||
AuthCodeSpotify::from_token_with_config(
|
||||
token,
|
||||
Credentials {
|
||||
id: env::SPOTIFY_CLIENT_ID.to_string(),
|
||||
secret: Some(env::SPOTIFY_CLIENT_SECRET.to_string()),
|
||||
},
|
||||
OAuth::default(),
|
||||
Config::default(),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user