mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-16 18:50:13 +00:00
fix(gateway): set custom prefix in bot status
This commit is contained in:
parent
e573e978da
commit
eb9994b215
3 changed files with 25 additions and 3 deletions
|
|
@ -63,6 +63,13 @@ pub fn create_shards(redis: fred::clients::RedisPool) -> anyhow::Result<Vec<Shar
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let prefix = libpk::config
|
||||||
|
.discord
|
||||||
|
.as_ref()
|
||||||
|
.expect("missing discord config")
|
||||||
|
.bot_prefix_for_gateway
|
||||||
|
.clone();
|
||||||
|
|
||||||
let shards = create_iterator(
|
let shards = create_iterator(
|
||||||
start_shard..end_shard + 1,
|
start_shard..end_shard + 1,
|
||||||
cluster_settings.total_shards,
|
cluster_settings.total_shards,
|
||||||
|
|
@ -75,7 +82,7 @@ pub fn create_shards(redis: fred::clients::RedisPool) -> anyhow::Result<Vec<Shar
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
intents,
|
intents,
|
||||||
)
|
)
|
||||||
.presence(presence("pk;help", false))
|
.presence(presence(format!("{prefix}help").as_str(), false))
|
||||||
.queue(queue.clone())
|
.queue(queue.clone())
|
||||||
.build(),
|
.build(),
|
||||||
|_, builder| builder.build(),
|
|_, builder| builder.build(),
|
||||||
|
|
|
||||||
|
|
@ -185,6 +185,15 @@ async fn main() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn scheduled_task(redis: RedisPool, senders: Vec<(ShardId, MessageSender)>) {
|
async fn scheduled_task(redis: RedisPool, senders: Vec<(ShardId, MessageSender)>) {
|
||||||
|
let prefix = libpk::config
|
||||||
|
.discord
|
||||||
|
.as_ref()
|
||||||
|
.expect("missing discord config")
|
||||||
|
.bot_prefix_for_gateway
|
||||||
|
.clone();
|
||||||
|
|
||||||
|
println!("{prefix}");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
tokio::time::sleep(Duration::from_secs(
|
tokio::time::sleep(Duration::from_secs(
|
||||||
(60 - chrono::offset::Utc::now().second()).into(),
|
(60 - chrono::offset::Utc::now().second()).into(),
|
||||||
|
|
@ -204,9 +213,9 @@ async fn scheduled_task(redis: RedisPool, senders: Vec<(ShardId, MessageSender)>
|
||||||
op: twilight_model::gateway::OpCode::PresenceUpdate,
|
op: twilight_model::gateway::OpCode::PresenceUpdate,
|
||||||
d: discord::gateway::presence(
|
d: discord::gateway::presence(
|
||||||
if let Some(status) = status {
|
if let Some(status) = status {
|
||||||
format!("pk;help | {}", status)
|
format!("{prefix}help | {status}")
|
||||||
} else {
|
} else {
|
||||||
"pk;help".to_string()
|
format!("{prefix}help")
|
||||||
}
|
}
|
||||||
.as_str(),
|
.as_str(),
|
||||||
false,
|
false,
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,16 @@ pub struct ClusterSettings {
|
||||||
pub total_nodes: u32,
|
pub total_nodes: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn _default_bot_prefix() -> String {
|
||||||
|
"pk;".to_string()
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct DiscordConfig {
|
pub struct DiscordConfig {
|
||||||
pub client_id: Id<UserMarker>,
|
pub client_id: Id<UserMarker>,
|
||||||
pub bot_token: String,
|
pub bot_token: String,
|
||||||
|
#[serde(default = "_default_bot_prefix")]
|
||||||
|
pub bot_prefix_for_gateway: String,
|
||||||
pub client_secret: String,
|
pub client_secret: String,
|
||||||
pub max_concurrency: u32,
|
pub max_concurrency: u32,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue