This repository was archived by the owner on Jun 17, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed
scripty_audio_handler/src
scripty_bot_utils/src/error Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 11use std:: time:: Duration ;
22
33use dashmap:: DashMap ;
4+ use scripty_data_type:: get_data;
45use serenity:: { gateway:: client:: Context , model:: id:: GuildId } ;
56use songbird:: error:: JoinError ;
67
78use crate :: error:: Error ;
89
9- pub async fn disconnect_from_vc ( _ctx : & Context , guild_id : GuildId ) -> Result < bool , Error > {
10+ pub async fn disconnect_from_vc ( ctx : & Context , guild_id : GuildId ) -> Result < bool , Error > {
1011 let sb = crate :: get_songbird ( ) ;
1112 let res = match sb. remove ( guild_id) . await {
1213 Ok ( ( ) ) => Ok ( true ) ,
1314 Err ( JoinError :: NoCall ) => Ok ( false ) ,
1415 Err ( e) => Err ( e. into ( ) ) ,
1516 } ;
1617
18+ get_data ( ctx) . existing_calls . force_remove_guild ( & guild_id) ;
19+
1720 let existing = super :: AUTO_LEAVE_TASKS
1821 . get_or_init ( || DashMap :: with_hasher ( ahash:: RandomState :: default ( ) ) )
1922 . remove ( & guild_id) ;
Original file line number Diff line number Diff line change @@ -261,7 +261,7 @@ impl Display for Error {
261261 AudioTranscription ( e) => format ! ( "Failed to transcribe audio message: {}" , e) . into ( ) ,
262262 KiaiError ( e) => format ! ( "Kiai API error: {}" , e) . into ( ) ,
263263 CallAlreadyExists => "a call for this channel already exists - not trying to rejoin \
264- the same channel"
264+ the same channel - run `/leave` if this is wrong "
265265 . into ( ) ,
266266 NoGuildDefaults => "no default configuration exists for this server" . into ( ) ,
267267 BadDiscordState => "Discord sent us bad data" . into ( ) ,
Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ impl CallLivenessMap {
2121 pub fn existing_channel_for_guild ( & self , guild_id : & GuildId ) -> Option < ChannelId > {
2222 Some ( self . 0 . get ( guild_id) ?. value ( ) . 0 )
2323 }
24+
25+ pub fn force_remove_guild ( & self , guild_id : & GuildId ) -> bool {
26+ self . 0 . remove ( guild_id) . is_some ( )
27+ }
2428}
2529
2630impl Default for CallLivenessMap {
@@ -66,7 +70,8 @@ impl Drop for CallDeath {
6670 last = true ;
6771 }
6872 } else {
69- unreachable ! ( "should be impossible to delete without the atomic value at 0" ) ;
73+ // FIXME: log this
74+ // "should be impossible to delete without the atomic value at 0"
7075 }
7176 if last {
7277 if let Some ( v) = self . inner . 0 . remove ( & self . guild_id ) {
You can’t perform that action at this time.
0 commit comments