Add support for custom shard ID and count
This commit is contained in:
+5
-3
@@ -113,7 +113,7 @@ use clap::Parser;
|
||||
use notify::{Event, EventKind, Watcher};
|
||||
use tokio::net::TcpListener;
|
||||
use tower_http::services::ServeDir;
|
||||
use twilight_gateway::Intents;
|
||||
use twilight_gateway::{Intents, ShardId};
|
||||
|
||||
use crate::{
|
||||
cli::{Args, Commands},
|
||||
@@ -165,8 +165,9 @@ pub async fn main() {
|
||||
Commands::Start {
|
||||
token,
|
||||
database_addr,
|
||||
shard,
|
||||
} => {
|
||||
start(token, database_addr).await;
|
||||
start(token, database_addr, shard.into()).await;
|
||||
}
|
||||
Commands::Docs { bind, open } => {
|
||||
docs(bind, open).await;
|
||||
@@ -202,7 +203,7 @@ impl PrefixGetter<State> for ServerPrefixOrPayphoneMention {
|
||||
/// Starts a Payphone shard.
|
||||
///
|
||||
/// TODO: Support multiple shards.
|
||||
async fn start(token: String, database_addr: String) {
|
||||
async fn start(token: String, database_addr: String, shard: ShardId) {
|
||||
log::info!("Welcome to Payphone, Nyeki!");
|
||||
log::info!(
|
||||
"Payphone is running on version v{}",
|
||||
@@ -218,6 +219,7 @@ async fn start(token: String, database_addr: String) {
|
||||
let state = State { db };
|
||||
|
||||
let bot = Bot::new(state, ServerPrefixOrPayphoneMention)
|
||||
.shard(shard)
|
||||
.intent(Intents::GUILDS)
|
||||
.intent(Intents::GUILD_MESSAGES)
|
||||
.intent(Intents::MESSAGE_CONTENT)
|
||||
|
||||
Reference in New Issue
Block a user