Compare commits
	
		
			4 Commits
		
	
	
		
			v1.5.9
			...
			66f45f11f2
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 66f45f11f2 | ||
|  | e30a08e019 | ||
|  | 80f45a1f5c | ||
|  | 1a1b1b8144 | 
							
								
								
									
										2
									
								
								.idea/dataSources.local.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.idea/dataSources.local.xml
									
									
									
										generated
									
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <project version="4"> | ||||
|   <component name="dataSourceStorageLocal" created-in="CL-231.8109.174"> | ||||
|   <component name="dataSourceStorageLocal" created-in="CL-231.9161.40"> | ||||
|     <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" /> | ||||
|       <secret-storage>master_key</secret-storage> | ||||
|   | ||||
| @@ -30,7 +30,10 @@ suggests = "mysql-server-8.0" | ||||
| maintainer-scripts = "debian" | ||||
| assets = [ | ||||
|     ["target/release/soundfx-rs", "usr/bin/soundfx-rs", "755"], | ||||
|     ["conf/default.env", "etc/soundfx-rs/default.env", "600"] | ||||
|     ["conf/default.env", "etc/soundfx-rs/config.env", "600"] | ||||
| ] | ||||
| conf-files = [ | ||||
|     "/etc/soundfx-rs/config.env", | ||||
| ] | ||||
|  | ||||
| [package.metadata.deb.systemd-units] | ||||
|   | ||||
							
								
								
									
										4
									
								
								debian/postinst
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								debian/postinst
									
									
									
									
										vendored
									
									
								
							| @@ -4,10 +4,6 @@ set -e | ||||
|  | ||||
| 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 | ||||
|  | ||||
| #DEBHELPER# | ||||
|   | ||||
							
								
								
									
										4
									
								
								debian/postrm
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								debian/postrm
									
									
									
									
										vendored
									
									
								
							| @@ -4,8 +4,4 @@ set -e | ||||
|  | ||||
| id -u soundfx &>/dev/null || userdel soundfx | ||||
|  | ||||
| if [ -f /etc/soundfx-rs/config.env ]; then | ||||
|   rm /etc/soundfx/config.env | ||||
| fi | ||||
|  | ||||
| #DEBHELPER# | ||||
|   | ||||
							
								
								
									
										8
									
								
								dump-query.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										8
									
								
								dump-query.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| mysql -D soundfx -N -e "SELECT name, hex(src) FROM sounds" > out | ||||
| split --additional-suffix=.row -l 1 out | ||||
| for filename in *.row; do | ||||
|     name=`grep -oP '^(.+)(?=\t)' $filename` | ||||
|     col=`awk -F '\t' '{print $2}' "$filename"` | ||||
|     echo $col > "$filename.hex" | ||||
|     xxd -r -p "$filename.hex" "$name.opus" | ||||
| done | ||||
| @@ -1,5 +1,6 @@ | ||||
| use poise::serenity_prelude::{ | ||||
|     builder::CreateActionRow, model::application::component::ButtonStyle, GuildChannel, | ||||
|     ReactionType, | ||||
| }; | ||||
|  | ||||
| use crate::{ | ||||
| @@ -316,21 +317,6 @@ pub async fn soundboard( | ||||
|     #[description = "Name or ID of sound for button 20"] | ||||
|     #[autocomplete = "autocomplete_sound"] | ||||
|     sound_20: Option<String>, | ||||
|     #[description = "Name or ID of sound for button 21"] | ||||
|     #[autocomplete = "autocomplete_sound"] | ||||
|     sound_21: Option<String>, | ||||
|     #[description = "Name or ID of sound for button 22"] | ||||
|     #[autocomplete = "autocomplete_sound"] | ||||
|     sound_22: Option<String>, | ||||
|     #[description = "Name or ID of sound for button 23"] | ||||
|     #[autocomplete = "autocomplete_sound"] | ||||
|     sound_23: Option<String>, | ||||
|     #[description = "Name or ID of sound for button 24"] | ||||
|     #[autocomplete = "autocomplete_sound"] | ||||
|     sound_24: Option<String>, | ||||
|     #[description = "Name or ID of sound for button 25"] | ||||
|     #[autocomplete = "autocomplete_sound"] | ||||
|     sound_25: Option<String>, | ||||
| ) -> Result<(), Error> { | ||||
|     ctx.defer().await?; | ||||
|  | ||||
| @@ -355,11 +341,6 @@ pub async fn soundboard( | ||||
|         sound_18, | ||||
|         sound_19, | ||||
|         sound_20, | ||||
|         sound_21, | ||||
|         sound_22, | ||||
|         sound_23, | ||||
|         sound_24, | ||||
|         sound_25, | ||||
|     ]; | ||||
|  | ||||
|     let mut sounds = vec![]; | ||||
| @@ -392,7 +373,33 @@ pub async fn soundboard( | ||||
|                 c.add_action_row(action_row); | ||||
|             } | ||||
|  | ||||
|             c | ||||
|             c.create_action_row(|r| { | ||||
|                 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?; | ||||
|   | ||||
| @@ -6,7 +6,7 @@ use poise::serenity_prelude::{ | ||||
|         channel::Channel, | ||||
|     }, | ||||
|     utils::shard_id, | ||||
|     Activity, Context, | ||||
|     ActionRowComponent, Activity, Context, CreateActionRow, CreateComponents, | ||||
| }; | ||||
|  | ||||
| use crate::{ | ||||
| @@ -137,23 +137,118 @@ SELECT name, id, public, server_id, uploader_id | ||||
|                 if let Some(guild_id) = component.guild_id { | ||||
|                     if let Ok(()) = SoundPager::handle_interaction(ctx, &data, component).await { | ||||
|                     } else { | ||||
|                         component | ||||
|                             .create_interaction_response(ctx, |r| { | ||||
|                                 r.kind(InteractionResponseType::DeferredUpdateMessage) | ||||
|                             }) | ||||
|                             .await | ||||
|                             .unwrap(); | ||||
|                         let mode = component.data.custom_id.as_str(); | ||||
|                         match mode { | ||||
|                             "#stop" => { | ||||
|                                 component | ||||
|                                     .create_interaction_response(ctx, |r| { | ||||
|                                         r.kind(InteractionResponseType::DeferredUpdateMessage) | ||||
|                                     }) | ||||
|                                     .await | ||||
|                                     .unwrap(); | ||||
|  | ||||
|                         play_from_query( | ||||
|                             &ctx, | ||||
|                             &data, | ||||
|                             guild_id.to_guild_cached(&ctx).unwrap(), | ||||
|                             component.user.id, | ||||
|                             None, | ||||
|                             &component.data.custom_id, | ||||
|                             false, | ||||
|                         ) | ||||
|                         .await; | ||||
|                                 let songbird = songbird::get(ctx).await.unwrap(); | ||||
|                                 let call_opt = songbird.get(guild_id); | ||||
|  | ||||
|                                 if let Some(call) = call_opt { | ||||
|                                     let mut lock = call.lock().await; | ||||
|  | ||||
|                                     lock.stop(); | ||||
|                                 } | ||||
|                             } | ||||
|  | ||||
|                             "#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; | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user