Skip to content

Commit

Permalink
cargo upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
tazz4843 committed Apr 4, 2024
1 parent 0298f85 commit 500ec1b
Show file tree
Hide file tree
Showing 22 changed files with 339 additions and 290 deletions.
456 changes: 240 additions & 216 deletions Cargo.lock

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions scripty_audio_handler/src/audio_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,24 +185,24 @@ impl EventHandler for AudioHandler {
self.guild_id,
*self.transcribe_only_role.read(),
)),
EventContext::VoiceTick(voice_data) => tokio::spawn(voice_tick(
voice_data.clone(),
Arc::clone(&self.ssrc_state),
self.guild_id,
self.voice_channel_id,
self.language.clone(),
self.verbose.clone(),
self.context.clone(),
Arc::clone(&self.webhook),
self.channel_id,
self.thread_id,
self.transcript_results.clone(),
Arc::clone(&self.automod_server_cfg),
Arc::clone(&self.auto_detect_lang),
Arc::clone(&self.translate),
Arc::clone(&self.kiai_enabled),
Arc::clone(&self.kiai_client),
)),
EventContext::VoiceTick(voice_data) => tokio::spawn(voice_tick(VoiceTickContext {
voice_data: voice_data.clone(),
ssrc_state: Arc::clone(&self.ssrc_state),
guild_id: self.guild_id,
voice_channel_id: self.voice_channel_id,
language: self.language.clone(),
verbose: self.verbose.clone(),
ctx: self.context.clone(),
webhook: Arc::clone(&self.webhook),
channel_id: self.channel_id,
thread_id: self.thread_id,
transcript_results: self.transcript_results.clone(),
automod_server_cfg: Arc::clone(&self.automod_server_cfg),
auto_detect_lang: Arc::clone(&self.auto_detect_lang),
translate: Arc::clone(&self.translate),
kiai_enabled: Arc::clone(&self.kiai_enabled),
kiai_client: Arc::clone(&self.kiai_client),
})),
EventContext::ClientDisconnect(client_disconnect_data) => {
tokio::spawn(client_disconnect(
*client_disconnect_data,
Expand Down
4 changes: 2 additions & 2 deletions scripty_audio_handler/src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub async fn connect_to_vc(
let hooks = channel_id.webhooks(ctx.http.as_ref()).await?;
let webhook = if hooks.is_empty() {
channel_id
.create_webhook(&ctx, CreateWebhook::new("Scripty Transcriptions"))
.create_webhook(&ctx.http, CreateWebhook::new("Scripty Transcriptions"))
.await?
} else {
// iterate through each hook and find one where token is not None
Expand All @@ -44,7 +44,7 @@ pub async fn connect_to_vc(
Some(hook) => hook,
None => {
channel_id
.create_webhook(&ctx, CreateWebhook::new("Scripty Transcriptions"))
.create_webhook(&ctx.http, CreateWebhook::new("Scripty Transcriptions"))
.await?
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripty_audio_handler/src/events/driver_disconnect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub async fn driver_disconnect(
"This transcript was automatically sent to all users who spoke in the voice chat.",
);
for user in seen_users.iter() {
match UserId::new(*user).create_dm_channel(&ctx).await {
match UserId::new(*user).create_dm_channel(&ctx.http).await {
Ok(user_channel) => {
if let Err(e) = user_channel.send_message(&ctx, message.clone()).await {
debug!(?guild_id, "failed to send transcript to {}: {}", *user, e);
Expand Down
2 changes: 1 addition & 1 deletion scripty_audio_handler/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ pub use client_disconnect::client_disconnect;
pub use driver_connect::driver_connect;
pub use driver_disconnect::driver_disconnect;
pub use speaking_state_update::speaking_state_update;
pub use voice_tick::voice_tick;
pub use voice_tick::{voice_tick, VoiceTickContext};
66 changes: 44 additions & 22 deletions scripty_audio_handler/src/events/voice_tick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,44 @@ use crate::{
types::{SsrcUserDataMap, TranscriptResults},
};

pub struct VoiceTickContext {
pub voice_data: VoiceTick,
pub ssrc_state: Arc<SsrcMaps>,
pub guild_id: GuildId,
pub voice_channel_id: ChannelId,
pub language: Arc<RwLock<String>>,
pub verbose: Arc<AtomicBool>,
pub ctx: Context,
pub webhook: Arc<Webhook>,
pub channel_id: ChannelId,
pub thread_id: Option<ChannelId>,
pub transcript_results: Option<Arc<RwLock<Vec<String>>>>,
pub automod_server_cfg: Arc<AutomodServerConfig>,
pub auto_detect_lang: Arc<AtomicBool>,
pub translate: Arc<AtomicBool>,
pub kiai_enabled: Arc<AtomicBool>,
pub kiai_client: KiaiApiClient,
}

pub async fn voice_tick(
voice_data: VoiceTick,
ssrc_state: Arc<SsrcMaps>,
guild_id: GuildId,
voice_channel_id: ChannelId,
language: Arc<RwLock<String>>,
verbose: Arc<AtomicBool>,
ctx: Context,
webhook: Arc<Webhook>,
channel_id: ChannelId,
thread_id: Option<ChannelId>,
transcript_results: Option<Arc<RwLock<Vec<String>>>>,
automod_server_cfg: Arc<AutomodServerConfig>,
auto_detect_lang: Arc<AtomicBool>,
translate: Arc<AtomicBool>,
kiai_enabled: Arc<AtomicBool>,
kiai_client: KiaiApiClient,
VoiceTickContext {
voice_data,
ssrc_state,
guild_id,
voice_channel_id,
language,
verbose,
ctx,
webhook,
channel_id,
thread_id,
transcript_results,
automod_server_cfg,
auto_detect_lang,
translate,
kiai_enabled,
kiai_client,
}: VoiceTickContext,
) {
let metrics = scripty_metrics::get_metrics();
let tick_start_time = Instant::now();
Expand All @@ -59,16 +80,16 @@ pub async fn voice_tick(
handle_speakers(Arc::clone(&ssrc_state), Arc::clone(&metrics), voice_data).await;

let hooks = handle_silent_speakers(SilentSpeakersContext {
ssrc_state: Arc::clone(&ssrc_state),
ssrc_state,
last_tick_speakers,
voice_channel_id,
language: Arc::clone(&language),
verbose: Arc::clone(&verbose),
language,
verbose,
guild_id,
channel_id,
thread_id,
automod_server_cfg: Arc::clone(&automod_server_cfg),
transcript_results: transcript_results.clone(),
automod_server_cfg,
transcript_results,
ctx: ctx.clone(),
auto_detect_lang,
translate,
Expand Down Expand Up @@ -124,7 +145,7 @@ async fn handle_silent_speakers<'a>(
automod_server_cfg,
transcript_results,
ctx,
auto_detect_lang: _,
auto_detect_lang,

Check warning on line 148 in scripty_audio_handler/src/events/voice_tick.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

unused variable: `auto_detect_lang`

warning: unused variable: `auto_detect_lang` --> scripty_audio_handler/src/events/voice_tick.rs:148:3 | 148 | auto_detect_lang, | ^^^^^^^^^^^^^^^^ help: try ignoring the field: `auto_detect_lang: _` | = note: `#[warn(unused_variables)]` on by default
translate,
kiai_enabled,
kiai_client,
Expand Down Expand Up @@ -492,6 +513,7 @@ async fn finalize_stream<'a>(
))
}

#[allow(dead_code)] // may be used in the future
fn handle_error<'a>(error: ModelError, ssrc: u32) -> ExecuteWebhook<'a> {
let user_error = match error {
ModelError::Io(io_err) => {
Expand Down
4 changes: 2 additions & 2 deletions scripty_bot_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ backtrace = "0.3"
num-format = "0.4"
async-trait = "0.1"
parking_lot = "0.12"
async-tempfile = { version = "0.4", features = ["uuid"] }
async-tempfile = { version = "0.5", features = ["uuid"] }
scripty_db = { path = "../scripty_db" }
scripty_stt = { path = "../scripty_stt" }
scripty_i18n = { path = "../scripty_i18n" }
Expand All @@ -29,7 +29,7 @@ scripty_botlists = { path = "../scripty_botlists" }
scripty_data_storage = { path = "../scripty_data_storage" }
scripty_audio_handler = { path = "../scripty_audio_handler" }
tokio = { version = "1", features = ["parking_lot", "signal"] }
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls"] }
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
serenity = { git = "https://github.com/serenity-rs/serenity", branch = "next", features = [
"voice",
"dashmap",
Expand Down
12 changes: 6 additions & 6 deletions scripty_bot_utils/src/dm_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl DmSupportStatus {
}
};

user.direct_message(&ctx, CreateMessage::default().embed(embed_builder))
user.direct_message(&ctx.http, CreateMessage::default().embed(embed_builder))
.await
};

Expand Down Expand Up @@ -217,7 +217,7 @@ impl DmSupportStatus {

let hook = channel
.create_webhook(
ctx,
&ctx.http,
CreateWebhook::new(user.tag()).avatar(
&CreateAttachment::url(
&ctx.http,
Expand Down Expand Up @@ -248,7 +248,7 @@ impl DmSupportStatus {

async fn handle_opening(&self, ctx: &Context, user: &User) -> serenity::Result<()> {
user.direct_message(
ctx,
&ctx.http,
CreateMessage::default().embed(
CreateEmbed::default()
.title("DM Ticket Opened")
Expand Down Expand Up @@ -278,7 +278,7 @@ impl DmSupportStatus {
}

let hook = channel
.create_webhook(ctx, CreateWebhook::new("Scripty"))
.create_webhook(&ctx.http, CreateWebhook::new("Scripty"))
.await
.expect("failed to create webhook");
self.webhook_cache.insert(*channel, hook.clone());
Expand Down Expand Up @@ -315,7 +315,7 @@ impl DmSupportStatus {

let _ = user
.direct_message(
&ctx,
&ctx.http,
CreateMessage::default().embed(
CreateEmbed::default()
.title("Closed Support Ticket")
Expand All @@ -331,7 +331,7 @@ impl DmSupportStatus {

self.webhook_cache.remove(&channel.id);

let _ = channel.delete(ctx).await;
let _ = channel.delete(ctx, Some("DM support ticket closed")).await;
}
}

Expand Down
6 changes: 1 addition & 5 deletions scripty_bot_utils/src/error/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,7 @@ async fn _on_error(error: FrameworkError<'_, Data, Error>) {
.await;
if let Err(e) = response {
warn!("failed to send message while handling error: {}", e);
let response = ctx
.interaction
.user
.direct_message(ctx.serenity_context(), msg)
.await;
let response = ctx.interaction.user.direct_message(ctx.http(), msg).await;
if let Err(e) = response {
error!("failed to DM user while handling error: {}", e)
}
Expand Down
2 changes: 1 addition & 1 deletion scripty_bot_utils/src/error/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub async fn send_err_msg<'a>(
warn!("failed to send message while handling error: {}", e);
let response = ctx
.author()
.direct_message(&ctx, CreateMessage::default().embed(embed))
.direct_message(ctx.http(), CreateMessage::default().embed(embed))
.await;
if let Err(e) = response {
error!("failed to DM user while handling error: {}", e)
Expand Down
4 changes: 2 additions & 2 deletions scripty_bot_utils/src/extern_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ pub fn get_cache_http() -> &'static CacheHttpWrapper {

#[derive(Clone)]
pub struct CacheHttpWrapper {
cache: Arc<Cache>,
http: Arc<Http>,
pub cache: Arc<Cache>,
pub http: Arc<Http>,
}

impl CacheHttp for CacheHttpWrapper {
Expand Down
2 changes: 1 addition & 1 deletion scripty_botlists/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "EUPL-1.2"

[dependencies]
serde = "1"
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls"] }
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
tracing = "0.1"
serde-aux = "4"
serde_json = "1"
Expand Down
2 changes: 1 addition & 1 deletion scripty_commands/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "EUPL-1.2"
[dependencies]
hex = "0.4"
tracing = "0.1"
indexmap = "1"
indexmap = "2"
humantime = "2"
typesize = "0.1"
num-format = "0.4"
Expand Down
5 changes: 3 additions & 2 deletions scripty_commands/src/cmds/admin/guild_check.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, fmt::Write, ops::Range};
use std::{collections::HashMap, fmt::Write, num::NonZeroU16, ops::Range};

use poise::CreateReply;
use serenity::{all::ShardId, gateway::ChunkGuildFilter};
Expand Down Expand Up @@ -46,7 +46,8 @@ pub async fn check_guilds(ctx: Context<'_>, specified_ratio: f64) -> Result<(),
.shard_manager
.get()
.ok_or(Error::custom("shard manager not initialized".to_string()))?;
let shard_count = shard_manager.runners.lock().await.len() as u16;
let shard_count = NonZeroU16::new(shard_manager.runners.lock().await.len() as u16)
.ok_or(Error::custom("shard count is zero".to_string()))?;

for guild in ctx.serenity_context().cache.guilds() {
let g = match guild.to_guild_cached(ctx.cache()) {
Expand Down
2 changes: 1 addition & 1 deletion scripty_commands/src/cmds/transcribe_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub async fn transcribe_message(ctx: Context<'_>) -> Result<(), Error> {
.await?;
}

ctx.msg.delete(&ctx).await?;
ctx.msg.delete(&ctx.http(), None).await?;

// the message gets sent in the above functions
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion scripty_data_storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ hound = "3"
dashmap = "5"
tracing = "0.1"
once_cell = "1"
ouroboros = "0.17"
ouroboros = "0.18"
parking_lot = "0.12"
scripty_db = { path = "../scripty_db" }
scripty_utils = { path = "../scripty_utils" }
Expand Down
2 changes: 1 addition & 1 deletion scripty_integrations/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ bitflags = "2"
serde_json = "1"
scripty_config = { path = "../scripty_config" }
serde = { version = "1", features = ["derive"] }
reqwest = { version = "0.11", features = ["rustls-tls", "json"], default-features = false }
reqwest = { version = "0.12", features = ["rustls-tls", "json"], default-features = false }
6 changes: 3 additions & 3 deletions scripty_redis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ license = "EUPL-1.2"

[dependencies]
tracing = "0.1"
deadpool = "0.10"
deadpool = "0.11"
once_cell = "1"
deadpool-redis = "0.14"
redis = { version = "0.24", features = ["tokio-rustls"] }
deadpool-redis = "0.15"
redis = { version = "0.25", features = ["tokio-rustls"] }
scripty_config = { path = "../scripty_config" }
4 changes: 3 additions & 1 deletion scripty_webserver/src/endpoints/premium/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,9 @@ ON CONFLICT
debug!("sending DM to user for premium event");
let cache_http = scripty_bot_utils::extern_utils::get_cache_http();

let dm_channel = UserId::from(user_id).create_dm_channel(cache_http).await?;
let dm_channel = UserId::from(user_id)
.create_dm_channel(&cache_http.http)
.await?;
dm_channel
.send_message(cache_http, CreateMessage::default().embed(embed))
.await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub async fn discordservices_net_incoming_webhook(

// send them a message
let cache_http = scripty_bot_utils::extern_utils::get_cache_http();
let dm_channel = UserId::new(id).create_dm_channel(&cache_http).await?;
let dm_channel = UserId::new(id).create_dm_channel(&cache_http.http).await?;
dm_channel
.send_message(
&cache_http,
Expand Down
4 changes: 3 additions & 1 deletion scripty_webserver/src/endpoints/webhooks/top_gg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ pub async fn top_gg_incoming_webhook(

// regardless, send them a message
let cache_http = scripty_bot_utils::extern_utils::get_cache_http();
let dm_channel = UserId::new(user).create_dm_channel(&cache_http).await?;
let dm_channel = UserId::new(user)
.create_dm_channel(&cache_http.http)
.await?;
dm_channel
.send_message(
&cache_http,
Expand Down
4 changes: 3 additions & 1 deletion scripty_webserver/src/endpoints/webhooks/wumpus_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ pub async fn wumpus_store_incoming_webhook(

// send them a message
let cache_http = scripty_bot_utils::extern_utils::get_cache_http();
let dm_channel = UserId::new(user_id).create_dm_channel(&cache_http).await?;
let dm_channel = UserId::new(user_id)
.create_dm_channel(&cache_http.http)
.await?;
dm_channel
.send_message(
&cache_http,
Expand Down

0 comments on commit 500ec1b

Please sign in to comment.