Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Commit c83c699

Browse files
committed
Update serenity/poise and update to Rust 2024
1 parent 022dc0a commit c83c699

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1179
-1020
lines changed

Cargo.lock

Lines changed: 753 additions & 643 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "scripty_v2"
33
version = "1.0.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

@@ -16,28 +16,28 @@ debug = true
1616

1717
[workspace]
1818
members = [
19-
"scripty_config",
20-
"scripty_webserver",
21-
"scripty_core",
22-
"scripty_premium",
23-
"scripty_stt",
24-
"scripty_audio_handler",
25-
"scripty_commands",
26-
"scripty_i18n",
27-
"scripty_db",
28-
"scripty_metrics",
29-
"scripty_utils",
30-
"scripty_data_storage",
31-
"scripty_redis",
32-
"scripty_bot",
33-
"scripty_bot_utils",
34-
"scripty_automod",
35-
"scripty_botlists",
36-
"scripty_error",
37-
"scripty_tts",
38-
"scripty_integrations",
39-
"scripty_build_checks",
40-
"scripty_data_type",
19+
"scripty_config",
20+
"scripty_webserver",
21+
"scripty_core",
22+
"scripty_premium",
23+
"scripty_stt",
24+
"scripty_audio_handler",
25+
"scripty_commands",
26+
"scripty_i18n",
27+
"scripty_db",
28+
"scripty_metrics",
29+
"scripty_utils",
30+
"scripty_data_storage",
31+
"scripty_redis",
32+
"scripty_bot",
33+
"scripty_bot_utils",
34+
"scripty_automod",
35+
"scripty_botlists",
36+
"scripty_error",
37+
"scripty_tts",
38+
"scripty_integrations",
39+
"scripty_build_checks",
40+
"scripty_data_type",
4141
]
4242

4343
[dependencies]

scripty_audio_handler/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "scripty_audio_handler"
33
version = "1.0.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "EUPL-1.2"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

scripty_audio_handler/src/audio_handler.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
use std::{
22
collections::VecDeque,
33
sync::{
4-
atomic::{AtomicBool, AtomicU8, Ordering},
54
Arc,
5+
atomic::{AtomicBool, AtomicU8, Ordering},
66
},
77
};
88

99
use ahash::RandomState;
1010
use dashmap::{DashMap, DashSet};
1111
use parking_lot::RwLock;
1212
use scripty_automod::types::AutomodServerConfig;
13-
use scripty_data_type::{get_data, CallDeath};
13+
use scripty_data_type::{CallDeath, get_data};
1414
use scripty_integrations::kiai::KiaiApiClient;
1515
use serenity::{
16-
all::RoleId,
1716
builder::ExecuteWebhook,
1817
gateway::client::Context,
1918
model::{
20-
id::{ChannelId, GuildId},
19+
id::{ChannelId, GuildId, RoleId, ThreadId},
2120
webhook::Webhook,
2221
},
2322
};
@@ -57,7 +56,7 @@ pub struct AudioHandler {
5756
guild_id: GuildId,
5857
channel_id: ChannelId,
5958
voice_channel_id: ChannelId,
60-
thread_id: Option<ChannelId>,
59+
thread_id: Option<ThreadId>,
6160
webhook: Arc<Webhook>,
6261
context: Context,
6362
premium_level: Arc<AtomicU8>,
@@ -82,7 +81,7 @@ impl AudioHandler {
8281
context: Context,
8382
channel_id: ChannelId,
8483
voice_channel_id: ChannelId,
85-
thread_id: Option<ChannelId>,
84+
thread_id: Option<ThreadId>,
8685
record_transcriptions: bool,
8786
automod_server_cfg: AutomodServerConfig,
8887
kiai_client: KiaiApiClient,
@@ -165,7 +164,7 @@ impl AudioHandler {
165164
// run cleanup tasks
166165
if ephemeral && let Some(thread_id) = t2.thread_id {
167166
let http = &t2.context.http;
168-
if let Err(e) = thread_id.delete(http, None).await {
167+
if let Err(e) = thread_id.widen().delete(http, None).await {
169168
let _ = t2
170169
.webhook
171170
.execute(
@@ -308,8 +307,7 @@ impl Clone for AudioHandler {
308307
let remaining = Arc::<_>::strong_count(&self.verbose);
309308
trace!(
310309
"{} references to AudioHandler {{ guild_id: {} }} left",
311-
remaining,
312-
self.guild_id
310+
remaining, self.guild_id
313311
);
314312

315313
Self {

scripty_audio_handler/src/connect.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ use serenity::{
66
builder::{CreateWebhook, ExecuteWebhook},
77
model::{
88
channel::ChannelType,
9-
id::{ChannelId, GuildId},
9+
id::{ChannelId, GuildId, ThreadId},
1010
},
1111
prelude::Context,
1212
};
13-
use songbird::{error::JoinError, events::Event, CoreEvent};
13+
use songbird::{CoreEvent, error::JoinError, events::Event};
1414

1515
use crate::Error;
1616

@@ -31,7 +31,7 @@ pub async fn connect_to_vc(
3131
guild_id: GuildId,
3232
transcript_target_channel: ChannelId,
3333
voice_channel_id: ChannelId,
34-
transcript_thread_id: Option<ChannelId>,
34+
transcript_thread_id: Option<ThreadId>,
3535
record_transcriptions: bool,
3636
ephemeral: bool,
3737
) -> Result<(), Error> {
@@ -53,19 +53,19 @@ pub async fn connect_to_vc(
5353
debug!(%guild_id, "checking type of target channel");
5454
// if the target channel is a thread we have to take its parent as the true target
5555
// and set the thread's ID to transcript_thread_id
56-
let (transcript_target_channel, transcript_thread_id) = {
56+
let (transcript_target_channel, transcript_thread_id): (ChannelId, Option<ThreadId>) = {
5757
let transcript_target_model = transcript_target_channel
5858
.to_guild_channel(&ctx, Some(guild_id))
5959
.await?;
6060
match (
61-
transcript_target_model.kind,
61+
transcript_target_model.base.kind,
6262
transcript_target_model.parent_id,
6363
) {
6464
// caught a thread as the target channel, fix that problem by using the parent instead
6565
(
6666
ChannelType::NewsThread | ChannelType::PublicThread | ChannelType::PrivateThread,
6767
Some(parent),
68-
) => (parent, Some(transcript_target_channel)),
68+
) => (parent, Some(ThreadId::new(transcript_target_channel.get()))),
6969

7070
// a thread with no parent? i must inform my supervisor post-haste!
7171
(

scripty_audio_handler/src/events/client_disconnect.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use std::sync::{
2-
atomic::{AtomicU8, Ordering},
32
Arc,
3+
atomic::{AtomicU8, Ordering},
44
};
55

66
use serenity::{
7-
all::{ChannelId, Context, Webhook},
87
builder::ExecuteWebhook,
8+
gateway::client::Context,
9+
model::{id::ThreadId, webhook::Webhook},
910
};
1011
use songbird::model::payload::ClientDisconnect;
1112

@@ -17,7 +18,7 @@ pub async fn client_disconnect(
1718
premium_level: Arc<AtomicU8>,
1819
ctx: Context,
1920
webhook: Arc<Webhook>,
20-
thread_id: Option<ChannelId>,
21+
thread_id: Option<ThreadId>,
2122
transcript_results: TranscriptResults,
2223
) {
2324
let user_id = client_disconnect_data.user_id;

scripty_audio_handler/src/events/driver_disconnect.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
use std::{borrow::Cow, sync::Arc};
22

33
use serenity::{
4-
all::UserId,
54
builder::{CreateAttachment, CreateMessage, ExecuteWebhook},
65
gateway::client::Context,
7-
model::{id::ChannelId, webhook::Webhook},
6+
model::{
7+
id::{ChannelId, ThreadId, UserId},
8+
webhook::Webhook,
9+
},
810
};
911
use songbird::{events::context_data::DisconnectReason, id::GuildId, model::CloseCode};
1012

@@ -21,7 +23,7 @@ pub async fn driver_disconnect(
2123
webhook: Arc<Webhook>,
2224
channel_id: ChannelId,
2325
voice_channel_id: ChannelId,
24-
thread_id: Option<ChannelId>,
26+
thread_id: Option<ThreadId>,
2527
transcript_results: TranscriptResults,
2628
seen_users: SeenUsers,
2729
ephemeral: bool,

scripty_audio_handler/src/events/voice_tick.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::{
22
borrow::Cow,
33
sync::{
4-
atomic::{AtomicBool, Ordering},
54
Arc,
5+
atomic::{AtomicBool, Ordering},
66
},
77
time::Instant,
88
};
@@ -15,9 +15,12 @@ use scripty_integrations::kiai::{KiaiApiClient, KiaiPostVirtualMessage};
1515
use scripty_metrics::Metrics;
1616
use scripty_stt::{ModelError, Stream};
1717
use serenity::{
18-
all::{ChannelId as SerenityChannelId, ChannelId, GuildId, UserId, Webhook},
1918
builder::{CreateEmbed, CreateMessage, EditMember, ExecuteWebhook},
2019
gateway::client::Context,
20+
model::{
21+
id::{ChannelId, GenericChannelId, GuildId, ThreadId, UserId},
22+
webhook::Webhook,
23+
},
2124
};
2225
use songbird::events::context_data::VoiceTick;
2326

@@ -37,7 +40,7 @@ pub struct VoiceTickContext {
3740
pub ctx: Context,
3841
pub webhook: Arc<Webhook>,
3942
pub channel_id: ChannelId,
40-
pub thread_id: Option<ChannelId>,
43+
pub thread_id: Option<ThreadId>,
4144
pub transcript_results: Option<Arc<RwLock<Vec<String>>>>,
4245
pub automod_server_cfg: Arc<AutomodServerConfig>,
4346
pub auto_detect_lang: Arc<AtomicBool>,
@@ -122,7 +125,7 @@ struct SilentSpeakersContext {
122125
verbose: Arc<AtomicBool>,
123126
guild_id: GuildId,
124127
channel_id: ChannelId,
125-
thread_id: Option<ChannelId>,
128+
thread_id: Option<ThreadId>,
126129
automod_server_cfg: Arc<AutomodServerConfig>,
127130
transcript_results: TranscriptResults,
128131
ctx: Context,
@@ -171,7 +174,7 @@ async fn handle_silent_speakers<'a>(
171174
// finalize the stream
172175
let lang = language.read().clone();
173176
let _typing = thread_id
174-
.unwrap_or(channel_id)
177+
.map_or_else(|| channel_id.widen(), ThreadId::widen)
175178
.start_typing(ctx.http.clone());
176179
let (final_result, hook) = match finalize_stream(
177180
old_stream,
@@ -233,7 +236,7 @@ async fn handle_silent_speakers<'a>(
233236
}
234237
}
235238

236-
if let Err(e) = SerenityChannelId::from(automod_server_cfg.log_channel_id)
239+
if let Err(e) = GenericChannelId::from(automod_server_cfg.log_channel_id)
237240
.send_message(
238241
&ctx.http,
239242
CreateMessage::new().embed(
@@ -464,7 +467,7 @@ async fn handle_speakers(ssrc_state: Arc<SsrcMaps>, metrics: Arc<Metrics>, voice
464467
async fn finalize_stream<'a>(
465468
stream: Stream,
466469
user_data_map: SsrcUserDataMap,
467-
thread_id: Option<ChannelId>,
470+
thread_id: Option<ThreadId>,
468471
ssrc: u32,
469472
language: String,
470473
verbose: &Arc<AtomicBool>,

scripty_audio_handler/src/lib.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ pub use disconnect::disconnect_from_vc;
1919
pub use error::{Error, ErrorKind};
2020
pub use scripty_stt::{check_model_language, get_model_languages};
2121
use serenity::all::{ChannelId, GuildId};
22-
use songbird::{driver::DecodeMode, Config};
23-
pub use songbird::{error::JoinError, Songbird};
22+
use songbird::{Config, driver::DecodeMode};
23+
pub use songbird::{Songbird, error::JoinError};
2424
use tokio::sync::{broadcast, oneshot::Sender};
2525

2626
use crate::audio_handler::SsrcMaps;
@@ -99,8 +99,7 @@ pub fn get_internal_state(guild_id: &GuildId) -> Option<InternalSsrcStateDetails
9999
let internal_maps = maps.get(guild_id)?;
100100
let v = internal_maps.value();
101101

102-
// go ahead and try getting rid of this binding i dare you :)
103-
let ret = Some(InternalSsrcStateDetails {
102+
Some(InternalSsrcStateDetails {
104103
seen_users: v.ssrc_user_id_map.iter().map(|x| *x.key()).collect(),
105104
ssrcs_with_stream: v.ssrc_stream_map.iter().map(|x| *x.key()).collect(),
106105
ssrcs_with_attached_data: v.ssrc_user_data_map.iter().map(|x| *x.key()).collect(),
@@ -112,7 +111,5 @@ pub fn get_internal_state(guild_id: &GuildId) -> Option<InternalSsrcStateDetails
112111
ssrcs_actively_speaking_this_tick: v.ssrc_speaking_set.iter().map(|x| *x).collect(),
113112
actively_transcribed_ssrcs: v.active_user_set.iter().map(|x| *x).collect(),
114113
next_ssrcs: v.next_user_list.read().iter().copied().collect(),
115-
});
116-
117-
ret
114+
})
118115
}

scripty_automod/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "scripty_automod"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "EUPL-1.2"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

0 commit comments

Comments
 (0)