Fix soundboard interactions not working for switching play mode

This commit is contained in:
jude 2025-02-25 18:25:15 +00:00
parent 6caca25719
commit c74c481d32

View File

@ -96,11 +96,10 @@ pub async fn listener(ctx: &Context, event: &FullEvent, data: &Data) -> Result<(
if let Some(guild_id) = component.guild_id { if let Some(guild_id) = component.guild_id {
if let Ok(()) = SoundPager::handle_interaction(ctx, &data, component).await { if let Ok(()) = SoundPager::handle_interaction(ctx, &data, component).await {
} else { } else {
component.defer(&ctx).await.unwrap();
let mode = component.data.custom_id.as_str(); let mode = component.data.custom_id.as_str();
match mode { match mode {
"#stop" => { "#stop" => {
component.defer(&ctx).await.unwrap();
let songbird = songbird::get(ctx).await.unwrap(); let songbird = songbird::get(ctx).await.unwrap();
let call_opt = songbird.get(guild_id); let call_opt = songbird.get(guild_id);
@ -123,30 +122,37 @@ pub async fn listener(ctx: &Context, event: &FullEvent, data: &Data) -> Result<(
ActionRowComponent::Button(button) => match &button ActionRowComponent::Button(button) => match &button
.data .data
{ {
ButtonKind::NonLink { custom_id, style } => row ButtonKind::NonLink { custom_id, style } => {
.push( let mut btn = CreateButton::new(
CreateButton::new( if custom_id.starts_with('#') {
if custom_id.starts_with('#') { custom_id.to_string()
custom_id.to_string() } else {
} else { format!(
format!( "{}{}",
"{}{}", custom_id
custom_id .split('#')
.split('#') .next()
.next() .unwrap(),
.unwrap(), mode
mode )
) },
}, )
) .disabled(
.label(button.label.clone().unwrap()) custom_id == "#mode"
.emoji(button.emoji.clone().unwrap()) || custom_id == mode,
.disabled( )
custom_id == "#mode" .style(*style);
|| custom_id == mode,
) if let Some(emoji) = button.emoji.clone() {
.style(*style), btn = btn.emoji(emoji);
), }
if let Some(label) = button.label.clone() {
btn = btn.label(label);
}
row.push(btn)
}
_ => {} _ => {}
}, },
_ => {} _ => {}
@ -165,8 +171,6 @@ pub async fn listener(ctx: &Context, event: &FullEvent, data: &Data) -> Result<(
} }
id_mode => { id_mode => {
component.defer(&ctx).await.unwrap();
let mut it = id_mode.split('#'); let mut it = id_mode.split('#');
let id = it.next().unwrap(); let id = it.next().unwrap();
let mode = it.next().unwrap_or("instant"); let mode = it.next().unwrap_or("instant");