fixed playing greet on all voice actions
This commit is contained in:
parent
35b3cb81c9
commit
4f2b57a9b3
24
src/main.rs
24
src/main.rs
@ -136,9 +136,10 @@ impl EventHandler for Handler {
|
|||||||
&self,
|
&self,
|
||||||
ctx: Context,
|
ctx: Context,
|
||||||
guild_id_opt: Option<GuildId>,
|
guild_id_opt: Option<GuildId>,
|
||||||
_old: Option<VoiceState>,
|
old: Option<VoiceState>,
|
||||||
new: VoiceState,
|
new: VoiceState,
|
||||||
) {
|
) {
|
||||||
|
if old.is_none() {
|
||||||
if let (Some(guild_id), Some(user_channel)) = (guild_id_opt, new.channel_id) {
|
if let (Some(guild_id), Some(user_channel)) = (guild_id_opt, new.channel_id) {
|
||||||
if let Some(guild) = ctx.cache.guild(guild_id).await {
|
if let Some(guild) = ctx.cache.guild(guild_id).await {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
@ -197,6 +198,16 @@ SELECT name, id, plays, public, server_id, uploader_id
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct LeaveInactive;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl SongbirdEventHandler for LeaveInactive {
|
||||||
|
async fn act(&self, ctx: &EventContext<'_>) -> Option<Event> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fn play_audio(
|
async fn play_audio(
|
||||||
sound: &mut Sound,
|
sound: &mut Sound,
|
||||||
@ -239,7 +250,7 @@ async fn join_channel(
|
|||||||
.get(¤t_user)
|
.get(¤t_user)
|
||||||
.and_then(|voice_state| voice_state.channel_id);
|
.and_then(|voice_state| voice_state.channel_id);
|
||||||
|
|
||||||
if current_voice_state == Some(channel_id) {
|
let (call, res) = if current_voice_state == Some(channel_id) {
|
||||||
let call_opt = songbird.get(guild.id);
|
let call_opt = songbird.get(guild.id);
|
||||||
|
|
||||||
if let Some(call) = call_opt {
|
if let Some(call) = call_opt {
|
||||||
@ -249,7 +260,14 @@ async fn join_channel(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
songbird.join(guild.id, channel_id).await
|
songbird.join(guild.id, channel_id).await
|
||||||
}
|
};
|
||||||
|
|
||||||
|
call.lock().await.add_global_event(
|
||||||
|
Event::Periodic(Duration::from_secs(300), None),
|
||||||
|
LeaveInactive {},
|
||||||
|
);
|
||||||
|
|
||||||
|
(call, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
// entry point
|
// entry point
|
||||||
|
Loading…
Reference in New Issue
Block a user