From e8080fb205d02838e820f0d9d07521710fb57ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 4 Apr 2020 06:49:57 +0300 Subject: [PATCH] Check client.stations exists in list, nowplaying and play commands. --- client/commands/list.js | 5 +++++ client/commands/nowplaying.js | 4 ++++ client/commands/play.js | 6 +++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/client/commands/list.js b/client/commands/list.js index 84daeb5..cfb4071 100644 --- a/client/commands/list.js +++ b/client/commands/list.js @@ -6,6 +6,11 @@ module.exports = { permission: 'none', category: 'info', execute(msg, args, client, Discord, command) { + let message = {}; + if(!client.stations) { + message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); + return msg.channel.send(client.messageEmojis["error"] + message.errorToGetPlaylist); + } let stations = `${client.stations.map(s => `**#** ${s.name}`).join('\n')}` const hashs = stations.split('**#**').length; for (let i = 0; i < hashs; i++) { diff --git a/client/commands/nowplaying.js b/client/commands/nowplaying.js index af20a2e..f3e8c2a 100644 --- a/client/commands/nowplaying.js +++ b/client/commands/nowplaying.js @@ -9,6 +9,10 @@ module.exports = { let message = {}; const radio = client.radio.get(msg.guild.id); if (!radio) return msg.channel.send('There is nothing playing.'); + if(!client.stations) { + message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); + return msg.channel.send(client.messageEmojis["error"] + message.errorToGetPlaylist); + } const completed = (radio.connection.dispatcher.streamTime.toFixed(0)); message.nowplayingDescription = client.messages.nowplayingDescription.replace("%radio.station.name%", radio.station.name); diff --git a/client/commands/play.js b/client/commands/play.js index 938b726..68e6098 100644 --- a/client/commands/play.js +++ b/client/commands/play.js @@ -6,6 +6,7 @@ module.exports = { permission: 'none', category: 'music', async execute(msg, args, client, Discord, command) { + let message = {}; let url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : ""; const radio = client.radio.get(msg.guild.id); const voiceChannel = msg.member.voice.channel; @@ -14,7 +15,10 @@ module.exports = { } else { if (voiceChannel !== radio.voiceChannel) return msg.channel.send(client.messageEmojis["error"] + client.messages.wrongVoiceChannel); } - if(!client.stations) return msg.channel.send(client.messageEmojis["error"] + client.messages.errorToGetPlaylist); + if(!client.stations) { + message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); + return msg.channel.send(client.messageEmojis["error"] + message.errorToGetPlaylist); + } if (!args[1]) return msg.channel.send(client.messages.noQuery); const permissions = voiceChannel.permissionsFor(msg.client.user); if (!permissions.has('CONNECT')) {