Added option to customize prefix in the config
This commit is contained in:
parent
909a2042da
commit
74cb49edfa
|
@ -8,3 +8,6 @@ mode = "+B"
|
||||||
# Spotify config
|
# Spotify config
|
||||||
spotify_client_id = ""
|
spotify_client_id = ""
|
||||||
spotify_client_secret = ""
|
spotify_client_secret = ""
|
||||||
|
|
||||||
|
# Bot config
|
||||||
|
prefix = "!"
|
||||||
|
|
22
src/main.rs
22
src/main.rs
|
@ -53,6 +53,7 @@ struct ClientConf {
|
||||||
username: String,
|
username: String,
|
||||||
spotify_client_id: String,
|
spotify_client_id: String,
|
||||||
spotify_client_secret: String,
|
spotify_client_secret: String,
|
||||||
|
prefix: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main(flavor = "current_thread")]
|
#[tokio::main(flavor = "current_thread")]
|
||||||
|
@ -65,23 +66,26 @@ async fn main() -> anyhow::Result<()> {
|
||||||
let mut client_conf = String::new();
|
let mut client_conf = String::new();
|
||||||
file.read_to_string(&mut client_conf).unwrap();
|
file.read_to_string(&mut client_conf).unwrap();
|
||||||
|
|
||||||
let config: ClientConf = toml::from_str(&client_conf).unwrap();
|
let client_config: ClientConf = toml::from_str(&client_conf).unwrap();
|
||||||
|
|
||||||
let spotify_creds = Credentials::new(&config.spotify_client_id, &config.spotify_client_secret);
|
let spotify_creds = Credentials::new(
|
||||||
|
&client_config.spotify_client_id,
|
||||||
|
&client_config.spotify_client_secret,
|
||||||
|
);
|
||||||
|
|
||||||
let config = Config::runtime_config(
|
let config = Config::runtime_config(
|
||||||
config.channels,
|
client_config.channels,
|
||||||
config.host,
|
client_config.host,
|
||||||
config.mode,
|
client_config.mode,
|
||||||
config.nickname,
|
client_config.nickname,
|
||||||
config.port,
|
client_config.port,
|
||||||
config.username,
|
client_config.username,
|
||||||
);
|
);
|
||||||
let mut client = Client::new(config).await?;
|
let mut client = Client::new(config).await?;
|
||||||
client.identify().await?;
|
client.identify().await?;
|
||||||
|
|
||||||
let state = AppState {
|
let state = AppState {
|
||||||
prefix: "!".to_string(),
|
prefix: client_config.prefix,
|
||||||
client,
|
client,
|
||||||
last_msgs: HashMap::new(),
|
last_msgs: HashMap::new(),
|
||||||
titlebot: Titlebot::create(spotify_creds).await?,
|
titlebot: Titlebot::create(spotify_creds).await?,
|
||||||
|
|
Loading…
Reference in a new issue