Skip to content

Commit

Permalink
Added empty video search results handling (#717)
Browse files Browse the repository at this point in the history
* Added empty video search results handling
  • Loading branch information
TIRTAGT committed May 4, 2021
1 parent 0946500 commit 7e64136
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 17 deletions.
6 changes: 6 additions & 0 deletions commands/play.js
Expand Up @@ -104,6 +104,12 @@ module.exports = {
} else {
try {
const results = await youtube.searchVideos(search, 1, { part: "snippet" });
// PATCH 1 : avoid cases when there are nothing on the search results.
if (results.length <= 0) {
// No video results.
message.reply(i18n.__mf("play.songNotFound")).catch(console.error);
return;
}
songInfo = await ytdl.getInfo(results[0].url);
song = {
title: songInfo.videoDetails.title,
Expand Down
2 changes: 1 addition & 1 deletion config.json.example
Expand Up @@ -8,4 +8,4 @@
"LOCALE": "en",
"STAY_TIME": 30,
"DEFAULT_VOLUME": 100
}
}
3 changes: 2 additions & 1 deletion locales/ar.json
Expand Up @@ -70,7 +70,8 @@
"increasedVolume": "<@{author}> 🔊 **{volume}%** زاد الصوت, مستوي الصوت الان هو",
"loopSong": "<@{author}> التكرار الان {loop}",
"stopSong": "<@{author}> أوقف الموسيقى ⏹",
"leaveChannel": "جارٍ ترك القناة الصوتية..."
"leaveChannel": "جارٍ ترك القناة الصوتية...",
"songNotFound": "Audio Not Found"
},
"playlist": {
"description": "تشغيل قائمة تشغيل من يوتيوب",
Expand Down
3 changes: 2 additions & 1 deletion locales/de.json
Expand Up @@ -70,7 +70,8 @@
"increasedVolume": "<@{author}> 🔊 hat die Lautstärke erhöht, sie ist jetzt auf {volume}%",
"loopSong": "<@{author}> Musikschleife ist nun auf {loop}",
"stopSong": "<@{author}> ⏹ hat die Musik gestoppt!",
"leaveChannel": "Verlasse den Voice-Channel..."
"leaveChannel": "Verlasse den Voice-Channel...",
"songNotFound": "Audio Not Found"
},
"playlist": {
"description": "Spielt eine Playlist von Youtube ab",
Expand Down
3 changes: 2 additions & 1 deletion locales/en.json
Expand Up @@ -70,7 +70,8 @@
"increasedVolume": "<@{author}> 🔊 increased the volume, the volume is now {volume}%",
"loopSong": "<@{author}> Loop is now {loop}",
"stopSong": "<@{author}> ⏹ stopped the music!",
"leaveChannel": "Leaving voice channel..."
"leaveChannel": "Leaving voice channel...",
"songNotFound": "Audio Not Found"
},
"playlist": {
"description": "Play a playlist from youtube",
Expand Down
3 changes: 2 additions & 1 deletion locales/es.json
Expand Up @@ -70,7 +70,8 @@
"increasedVolume": "<@{author}> 🔊 Subió el volumen de la música, el volumen actual ahora es {volume}%",
"loopSong": "<@{author}> El bucle actual es {loop}",
"stopSong": "<@{author}> ⏹ ¡Paró la música!",
"leaveChannel": "Saliendo del chat de voz..."
"leaveChannel": "Saliendo del chat de voz...",
"songNotFound": "Audio Not Found"
},
"playlist": {
"description": "Reproduce una lista de reproducción de youtube",
Expand Down
3 changes: 2 additions & 1 deletion locales/fr.json
Expand Up @@ -64,7 +64,8 @@
"increasedVolume": "<@{author}> 🔊 augmente le volume, le volume est maintenant {volume}%",
"loopSong": "<@{author}> Loop est maintenant {loop}",
"stopSong": "<@{author}> ⏹ arrête la musique!",
"leaveChannel": "Quitte le salon vocal..."
"leaveChannel": "Quitte le salon vocal...",
"songNotFound": "Audio Not Found"
},
"playlist": {
"description": "Écoute une playlist venant de YouTube",
Expand Down
3 changes: 2 additions & 1 deletion locales/it.json
Expand Up @@ -70,7 +70,8 @@
"increasedVolume": "<@{author}> 🔊 aumentato il volume, il volume è ora {volume}%",
"loopSong": "<@{author}> Ora in riproduzione {loop}",
"stopSong": "<@{author}> ⏹ fermato la musica!",
"leaveChannel": "Uscita dal canale vocale ..."
"leaveChannel": "Uscita dal canale vocale ...",
"songNotFound": "Audio Not Found"
},
"playlist": {
"description": "Riproduci una playlist da youtube",
Expand Down
3 changes: 2 additions & 1 deletion locales/ko.json
Expand Up @@ -70,7 +70,8 @@
"increasedVolume": "<@{author}> 🔊 볼륨을 높어, 현재 {volume}% 로 설정되어 있습니다",
"loopSong": "<@{author}> 음악 반복 상태: {loop}",
"stopSong": "<@{author}> ⏹ 음악을 중지했습니다.",
"leaveChannel": "채널을 떠나는 중입니다."
"leaveChannel": "채널을 떠나는 중입니다.",
"songNotFound": "Audio Not Found"
},
"playlist": {
"description": "Youtube 부터 재생목록을 재생합니다.",
Expand Down
3 changes: 2 additions & 1 deletion locales/nl.json
Expand Up @@ -70,7 +70,8 @@
"increasedVolume": "<@{author}> 🔊 verhoogde het volume, het volume is nu {volume}%",
"loopSong": "<@{author}> Herhaling is nu {loop}",
"stopSong": "<@{author}> ⏹ stopte de muziek!",
"leaveChannel": "Voice channel verlaten..."
"leaveChannel": "Voice channel verlaten...",
"songNotFound": "Audio Not Found"
},
"playlist": {
"description": "Speel een playlist af van youtube",
Expand Down
3 changes: 2 additions & 1 deletion locales/pl.json
Expand Up @@ -70,7 +70,8 @@
"increasedVolume": "<@{author}> 🔊 podniósł poziom głośności, wynosi teraz: {volume}%",
"loopSong": "<@{author}> Przełączył pętlę na: {loop}",
"stopSong": "<@{author}> ⏹ Zatrzymał odtwarzanie!",
"leaveChannel": "Opuszczanie kanału głosowego..."
"leaveChannel": "Opuszczanie kanału głosowego...",
"songNotFound": "Audio Not Found"
},
"playlist": {
"description": "Odtwarza listę odtwarzania z youtuba",
Expand Down
3 changes: 2 additions & 1 deletion locales/pt_br.json
Expand Up @@ -70,7 +70,8 @@
"increasedVolume": "<@{author}> 🔊 aumentou o volume, o volume agora é {volume}%",
"loopSong": "<@{author}> Repetir está {loop}",
"stopSong": "<@{author}> ⏹ parou a música!",
"leaveChannel": "Deixando o canal de voz!"
"leaveChannel": "Deixando o canal de voz!",
"songNotFound": "Audio Not Found"
},
"playlist": {
"description": "Reproduz uma playlist do youtube",
Expand Down
3 changes: 2 additions & 1 deletion locales/ru.json
Expand Up @@ -70,7 +70,8 @@
"increasedVolume": "<@{author}> 🔊 увеличил громкость, теперь громкость {volume}%",
"loopSong": "<@{author}> Сейчас Повторяется {loop}",
"stopSong": "<@{author}> ⏹ остановил музыку!",
"leaveChannel": "Выход из голосового канала..."
"leaveChannel": "Выход из голосового канала...",
"songNotFound": "Audio Not Found"
},
"playlist": {
"description": "Воспроизвести плейлист с YouTube",
Expand Down
3 changes: 2 additions & 1 deletion locales/sv.json
Expand Up @@ -70,7 +70,8 @@
"increasedVolume": "<@{author}> 🔊 ökade volymen, volymen är nu {volume}%",
"loopSong": "<@{author}> Loop är nu {loop}",
"stopSong": "<@{author}> ⏹ stoppade musiken!",
"leaveChannel": "Lämna röstkanal..."
"leaveChannel": "Lämna röstkanal...",
"songNotFound": "Audio Not Found"
},
"playlist": {
"description": "Spela en spellista från youtube",
Expand Down
3 changes: 2 additions & 1 deletion locales/tr.json
Expand Up @@ -70,7 +70,8 @@
"increasedVolume": "<@{author}> 🔊 sesi artırdı ses seviyesi {volume}%",
"loopSong": "<@{author}> Döngü şuan {loop}",
"stopSong": "<@{author}> ⏹ müziği durdurdu!",
"leaveChannel": "Sesli kanaldan çıkıyor..."
"leaveChannel": "Sesli kanaldan çıkıyor...",
"songNotFound": "Audio Not Found"
},
"playlist": {
"description": "Youtubeden bir çalma listesi oynat",
Expand Down
3 changes: 2 additions & 1 deletion locales/zh_cn.json
Expand Up @@ -70,7 +70,8 @@
"increasedVolume": "<@{author}> 🔊 增加了音量, 目前音量为 {volume}%",
"loopSong": "<@{author}> 重複播放目前是 {loop}",
"stopSong": "<@{author}> ⏹ 停止了歌曲!",
"leaveChannel": "正在离开语音频道..."
"leaveChannel": "正在离开语音频道...",
"songNotFound": "Audio Not Found"
},
"playlist": {
"description": "播放 YouTube 的播放清单",
Expand Down
3 changes: 2 additions & 1 deletion locales/zh_tw.json
Expand Up @@ -70,7 +70,8 @@
"increasedVolume": "<@{author}> 🔊 增加了音量, 目前音量為 {volume}%",
"loopSong": "<@{author}> 重複播放目前是 {loop}",
"stopSong": "<@{author}> ⏹ 停止了歌曲!",
"leaveChannel": "正在離開語音頻道..."
"leaveChannel": "正在離開語音頻道...",
"songNotFound": "Audio Not Found"
},
"playlist": {
"description": "播放 YouTube 的播放清單",
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7e64136

Please sign in to comment.