Compare commits

..

No commits in common. "66f45f11f27e0220b51b2954631faa9d7eebe72e" and "80f45a1f5c30d8c6aa7a54c58643649cd254f142" have entirely different histories.

6 changed files with 28 additions and 145 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="dataSourceStorageLocal" created-in="CL-231.9161.40"> <component name="dataSourceStorageLocal" created-in="CL-231.8109.174">
<data-source name="MySQL for 5.1 - soundfx@localhost" uuid="1067c1d0-1386-4a39-b3f5-6d48d6f279eb"> <data-source name="MySQL for 5.1 - soundfx@localhost" uuid="1067c1d0-1386-4a39-b3f5-6d48d6f279eb">
<database-info product="" version="" jdbc-version="" driver-name="" driver-version="" dbms="MYSQL" exact-version="0" /> <database-info product="" version="" jdbc-version="" driver-name="" driver-version="" dbms="MYSQL" exact-version="0" />
<secret-storage>master_key</secret-storage> <secret-storage>master_key</secret-storage>

View File

@ -30,10 +30,7 @@ suggests = "mysql-server-8.0"
maintainer-scripts = "debian" maintainer-scripts = "debian"
assets = [ assets = [
["target/release/soundfx-rs", "usr/bin/soundfx-rs", "755"], ["target/release/soundfx-rs", "usr/bin/soundfx-rs", "755"],
["conf/default.env", "etc/soundfx-rs/config.env", "600"] ["conf/default.env", "etc/soundfx-rs/default.env", "600"]
]
conf-files = [
"/etc/soundfx-rs/config.env",
] ]
[package.metadata.deb.systemd-units] [package.metadata.deb.systemd-units]

4
debian/postinst vendored
View File

@ -4,6 +4,10 @@ set -e
id -u soundfx &>/dev/null || useradd -r -M soundfx id -u soundfx &>/dev/null || useradd -r -M soundfx
if [ ! -f /etc/soundfx-rs/config.env ]; then
cp /etc/soundfx-rs/default.env /etc/soundfx-rs/config.env
fi
chown soundfx /etc/soundfx-rs/config.env chown soundfx /etc/soundfx-rs/config.env
#DEBHELPER# #DEBHELPER#

4
debian/postrm vendored
View File

@ -4,4 +4,8 @@ set -e
id -u soundfx &>/dev/null || userdel soundfx id -u soundfx &>/dev/null || userdel soundfx
if [ -f /etc/soundfx-rs/config.env ]; then
rm /etc/soundfx-rs/config.env
fi
#DEBHELPER# #DEBHELPER#

View File

@ -1,6 +1,5 @@
use poise::serenity_prelude::{ use poise::serenity_prelude::{
builder::CreateActionRow, model::application::component::ButtonStyle, GuildChannel, builder::CreateActionRow, model::application::component::ButtonStyle, GuildChannel,
ReactionType,
}; };
use crate::{ use crate::{
@ -373,33 +372,7 @@ pub async fn soundboard(
c.add_action_row(action_row); c.add_action_row(action_row);
} }
c.create_action_row(|r| { c
r.create_button(|b| {
b.label("Stop")
.emoji(ReactionType::Unicode("".to_string()))
.style(ButtonStyle::Danger)
.custom_id("#stop")
})
.create_button(|b| {
b.label("Mode:")
.style(ButtonStyle::Secondary)
.disabled(true)
.custom_id("#mode")
})
.create_button(|b| {
b.label("Instant")
.emoji(ReactionType::Unicode("".to_string()))
.style(ButtonStyle::Secondary)
.disabled(true)
.custom_id("#instant")
})
.create_button(|b| {
b.label("Loop")
.emoji(ReactionType::Unicode("🔁".to_string()))
.style(ButtonStyle::Secondary)
.custom_id("#loop")
})
})
}) })
}) })
.await?; .await?;

View File

@ -6,7 +6,7 @@ use poise::serenity_prelude::{
channel::Channel, channel::Channel,
}, },
utils::shard_id, utils::shard_id,
ActionRowComponent, Activity, Context, CreateActionRow, CreateComponents, Activity, Context,
}; };
use crate::{ use crate::{
@ -137,118 +137,23 @@ SELECT name, id, public, server_id, uploader_id
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 {
let mode = component.data.custom_id.as_str(); component
match mode { .create_interaction_response(ctx, |r| {
"#stop" => { r.kind(InteractionResponseType::DeferredUpdateMessage)
component })
.create_interaction_response(ctx, |r| { .await
r.kind(InteractionResponseType::DeferredUpdateMessage) .unwrap();
})
.await
.unwrap();
let songbird = songbird::get(ctx).await.unwrap(); play_from_query(
let call_opt = songbird.get(guild_id); &ctx,
&data,
if let Some(call) = call_opt { guild_id.to_guild_cached(&ctx).unwrap(),
let mut lock = call.lock().await; component.user.id,
None,
lock.stop(); &component.data.custom_id,
} false,
} )
.await;
"#loop" | "#queue" | "#instant" => {
component
.create_interaction_response(ctx, |r| {
r.kind(InteractionResponseType::UpdateMessage)
.interaction_response_data(|d| {
let mut c: CreateComponents = Default::default();
for action_row in &component.message.components {
let mut a: CreateActionRow = Default::default();
// These are always buttons
for component in &action_row.components {
match component {
ActionRowComponent::Button(button) => {
a.create_button(|b| {
if let Some(label) =
&button.label
{
b.label(label);
}
if let Some(emoji) =
&button.emoji
{
b.emoji(emoji.clone());
}
if let Some(custom_id) =
&button.custom_id
{
if custom_id
.starts_with('#')
{
b.custom_id(custom_id)
.disabled(
custom_id
== "#mode"
|| custom_id
== mode,
);
} else {
b.custom_id(format!(
"{}{}",
custom_id
.split('#')
.next()
.unwrap(),
mode
));
}
}
b.style(button.style);
b
});
}
_ => {}
}
}
c.add_action_row(a);
}
d.set_components(c)
})
})
.await
.unwrap();
}
id_mode => {
component
.create_interaction_response(ctx, |r| {
r.kind(InteractionResponseType::DeferredUpdateMessage)
})
.await
.unwrap();
let mut it = id_mode.split('#');
let id = it.next().unwrap();
let mode = it.next().unwrap_or("instant");
play_from_query(
&ctx,
&data,
guild_id.to_guild_cached(&ctx).unwrap(),
component.user.id,
None,
id.split('#').next().unwrap(),
mode == "loop",
)
.await;
}
}
} }
} }
} }