From 87360465d102bb6bc2e57c36f1c9a2e771da6e0d Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Mon, 20 Nov 2023 20:14:15 +0500 Subject: [PATCH] fix play.c if there is no link in message --- commands/Music/play.c.js | 5 ++++- languages/en-US/music/play.json | 2 +- languages/ru-RU/music/play.json | 2 +- languages/uk-UA/music/play.json | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/commands/Music/play.c.js b/commands/Music/play.c.js index 20533d28..37e245dc 100644 --- a/commands/Music/play.c.js +++ b/commands/Music/play.c.js @@ -33,7 +33,10 @@ class PlayContext extends BaseCommand { async execute(client, interaction) { await interaction.deferReply(); - const query = interaction.targetMessage.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g)[0], + const links = interaction.targetMessage.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g); + if (!links) return interaction.error("music/play:NO_LINK", null, { edit: true }); + + const query = links[0], voice = interaction.member.voice.channel; if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL", null, { edit: true }); diff --git a/languages/en-US/music/play.json b/languages/en-US/music/play.json index 20fafa99..753401de 100644 --- a/languages/en-US/music/play.json +++ b/languages/en-US/music/play.json @@ -3,9 +3,9 @@ "USAGE": "[query]", "EXAMPLES": "play query:Never Gonna Give You Up", "QUERY": "Title / Direct link / YouTube, Spotify, or SoundCloud link", + "NO_LINK": "This message doesn't contain any links", "NO_VOICE_CHANNEL": "You must be in a voice channel", "VOICE_CHANNEL_CONNECT": "I cannot connect to your voice channel", - "RESULTS_TITLE": "Search results for \"{{query}}\"", "NO_RESULT": "No results found for `{{query}}`", "NOW_PLAYING": "Now playing **{{songName}}**", "NOT_PLAYING": "Nothing is currently playing on the server", diff --git a/languages/ru-RU/music/play.json b/languages/ru-RU/music/play.json index 12e5f291..8d8579cf 100644 --- a/languages/ru-RU/music/play.json +++ b/languages/ru-RU/music/play.json @@ -3,9 +3,9 @@ "USAGE": "[query]", "EXAMPLES": "play query:Never Gonna Give You Up", "QUERY": "Название / Прямая ссылка / Ссылка на YouTube, Spotify или SoundCloud", + "NO_LINK": "В данном сообщении нет ссылок", "NO_VOICE_CHANNEL": "Вы должны находиться в голосовом канале", "VOICE_CHANNEL_CONNECT": "Я не могу присоедениться к вашему голосовому каналу", - "RESULTS_TITLE": "Результаты поиска по \"{{query}}\"", "NO_RESULT": "По запросу `{{query}}` ничего не найдено", "NOW_PLAYING": "Сейчас играет **{{songName}}**", "NOT_PLAYING": "На сервере сейчас ничего не воспроизводится", diff --git a/languages/uk-UA/music/play.json b/languages/uk-UA/music/play.json index 29a97b90..cbd23342 100644 --- a/languages/uk-UA/music/play.json +++ b/languages/uk-UA/music/play.json @@ -3,9 +3,9 @@ "USAGE": "[query]", "EXAMPLES": "play query:Never Gonna Give You Up", "QUERY": "Назва / Пряме посилання / Посилання на YouTube, Spotify або SoundCloud", + "NO_LINK": "У цьому повідомленні немає посилань", "NO_VOICE_CHANNEL": "Ви повинні знаходитися в голосовому каналі", "VOICE_CHANNEL_CONNECT": "Я не можу приєднатися до вашого голосового каналу", - "RESULTS_TITLE": "Результати пошуку за \"{{query}}\"", "NO_RESULT": "За запитом `{{query}}` нічого не знайдено", "NOW_PLAYING": "Зараз грає **{{songName}}**", "NOT_PLAYING": "На сервері зараз нічого не відтворюється",