@@ -41,12 +41,9 @@ async fn get_channel_info(ctx: &Context, voice_state: &VoiceState) -> Option<(Ch
41
41
. ok ( ) ?;
42
42
43
43
// Ignore all channels other than voice channels.
44
- let guild_channel = match channel {
45
- Channel :: Guild ( guild_channel) => guild_channel,
46
- _ => {
47
- println ! ( "Got something other than a guild channel" ) ;
48
- return None ;
49
- }
44
+ let Channel :: Guild ( guild_channel) = channel else {
45
+ println ! ( "Got something other than a guild channel" ) ;
46
+ return None ;
50
47
} ;
51
48
if guild_channel. kind != ChannelType :: Voice {
52
49
println ! ( "Got something other than a voice channel" ) ;
@@ -55,15 +52,16 @@ async fn get_channel_info(ctx: &Context, voice_state: &VoiceState) -> Option<(Ch
55
52
println ! ( "Got event for channel called \" {}\" " , guild_channel. name( ) ) ;
56
53
57
54
// Find out how many folks are in that voice channel.
58
- let member_count = match guild_channel. members ( & ctx) . await {
59
- Ok ( members) => members. len ( ) ,
60
- Err ( why) => {
55
+ let members = guild_channel
56
+ . members ( & ctx)
57
+ . await
58
+ . or_else ( |why| {
61
59
println ! ( "Failed to get member count: {:?}" , why) ;
62
- return None ;
63
- }
64
- } ;
60
+ return Err ( why ) ;
61
+ } )
62
+ . ok ( ) ? ;
65
63
66
- Some ( ( id, member_count ) )
64
+ Some ( ( id, members . len ( ) ) )
67
65
}
68
66
69
67
#[ async_trait]
@@ -132,9 +130,11 @@ async fn get_discord_token() -> String {
132
130
return token;
133
131
}
134
132
let token_file = env:: var ( "DISCORD_TOKEN_FILE" ) . expect ( "Could not read DISCORD_TOKEN_FILE" ) ;
135
- let contents = tokio:: fs:: read_to_string ( & token_file) . await . unwrap_or_else ( |why| {
136
- panic ! ( "Failed to read {}: {:?}" , token_file. as_str( ) , why) ;
137
- } ) ;
133
+ let contents = tokio:: fs:: read_to_string ( & token_file)
134
+ . await
135
+ . unwrap_or_else ( |why| {
136
+ panic ! ( "Failed to read {}: {:?}" , token_file. as_str( ) , why) ;
137
+ } ) ;
138
138
contents
139
139
}
140
140
0 commit comments