mirror of
				https://github.com/warengroup/eximiabots-radiox.git
				synced 2025-10-26 07:13:08 +00:00 
			
		
		
		
	Add direct search to Stations class
This commit is contained in:
		| @@ -41,7 +41,7 @@ module.exports = class Radio extends Map { | |||||||
|             if(voiceChannel.members.filter(member => !member.user.bot).size === 0) return; |             if(voiceChannel.members.filter(member => !member.user.bot).size === 0) return; | ||||||
|  |  | ||||||
|  |  | ||||||
|             const sstation = await client.stations.search(state.station.name); |             const sstation = await client.stations.search(state.station.name, "direct"); | ||||||
|             let station = sstation; |             let station = sstation; | ||||||
|  |  | ||||||
|             if(!station) return; |             if(!station) return; | ||||||
|   | |||||||
| @@ -60,9 +60,20 @@ module.exports = class Stations extends Array { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     search(key) { |     search(key, type) { | ||||||
|         if (this === null) return false; |         if (this === null) return false; | ||||||
|         if (!key) return false; |         if (!key) return false; | ||||||
|  |         if (!type) return false; | ||||||
|  |  | ||||||
|  |         if(type == "direct"){ | ||||||
|  |             let foundStation; | ||||||
|  |             this.forEach(station => { | ||||||
|  |                 if(station.name != key) return false; | ||||||
|  |                 foundStation = station; | ||||||
|  |             }); | ||||||
|  |  | ||||||
|  |             return foundStation; | ||||||
|  |         } else { | ||||||
|  |  | ||||||
|             let foundStations = []; |             let foundStations = []; | ||||||
|             if (key == "radio") return false; |             if (key == "radio") return false; | ||||||
| @@ -123,4 +134,5 @@ module.exports = class Stations extends Array { | |||||||
|             } |             } | ||||||
|             return highestProbabilityStation; |             return highestProbabilityStation; | ||||||
|         } |         } | ||||||
|  |     } | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -84,7 +84,16 @@ module.exports = { | |||||||
|                 content: client.messageEmojis["error"] + client.messages.tooShortSearch, |                 content: client.messageEmojis["error"] + client.messages.tooShortSearch, | ||||||
|                 ephemeral: true |                 ephemeral: true | ||||||
|             }); |             }); | ||||||
|             const sstation = await client.stations.search(query, client); |  | ||||||
|  |             let type = ""; | ||||||
|  |  | ||||||
|  |             if(interaction.values?.[0]){ | ||||||
|  |                 type = "direct"; | ||||||
|  |             } else { | ||||||
|  |                 type = "text"; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             const sstation = await client.stations.search(query, type); | ||||||
|             if (!sstation) return interaction.reply({ |             if (!sstation) return interaction.reply({ | ||||||
|                 content: client.messageEmojis["error"] + client.messages.noSearchResults, |                 content: client.messageEmojis["error"] + client.messages.noSearchResults, | ||||||
|                 ephemeral: true |                 ephemeral: true | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Christer Warén
					Christer Warén