Skip to content

Commit

Permalink
Add proxy config
Browse files Browse the repository at this point in the history
  • Loading branch information
tazz4843 committed Mar 17, 2024
1 parent e0dfebf commit 734cff4
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions scripty_bot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::sync::{Arc, OnceLock};

use poise::FrameworkBuilder;
use scripty_bot_utils::{globals::CLIENT_DATA, handler, Data};
use serenity::{all::OnlineStatus, gateway::ActivityData};
use serenity::{all::OnlineStatus, client::ClientBuilder, gateway::ActivityData};

pub async fn entrypoint() {
// fetch the config
Expand Down Expand Up @@ -38,17 +38,24 @@ pub async fn entrypoint() {
);
scripty_audio_handler::set_songbird(songbird.clone());

let mut client =
serenity::Client::builder(&cfg.tokens.discord, framework_opts::get_gateway_intents())
.data(data.clone())
.framework(framework)
.voice_manager::<scripty_audio_handler::Songbird>(songbird)
.event_handler(handler::BotEventHandler)
.raw_event_handler(handler::RawEventHandler)
.status(OnlineStatus::Idle)
.activity(ActivityData::custom("Starting up..."))
.await
.expect("failed to create serenity client");
let mut http = serenity::http::HttpBuilder::new(&cfg.tokens.discord);
if let Some(proxy) = &cfg.proxy {
http = http.proxy(proxy).ratelimiter_disabled(true);
}

let mut client = ClientBuilder::new_with_http(
Arc::new(http.build()),
framework_opts::get_gateway_intents(),
)
.data(data.clone())
.framework(framework)
.voice_manager::<scripty_audio_handler::Songbird>(songbird)
.event_handler(handler::BotEventHandler)
.raw_event_handler(handler::RawEventHandler)
.status(OnlineStatus::Idle)
.activity(ActivityData::custom("Starting up..."))
.await
.expect("failed to create serenity client");

data.shard_manager
.set(client.shard_manager.clone())
Expand Down

0 comments on commit 734cff4

Please sign in to comment.