diff --git a/commands/bug.js b/commands/bug.js index 44132e1..bc4377e 100644 --- a/commands/bug.js +++ b/commands/bug.js @@ -6,11 +6,18 @@ module.exports = { permission: 'none', category: 'info', async execute(msg, args, client, Discord, prefix) { + let message = {}; + + message.bugTitle = client.messages.bugTitle.replace("%client.user.username%", client.user.username); + message.bugDescription = client.messages.bugDescription.replace("%client.developers%", client.developers); + message.bugDescription = message.bugDescription.replace("%client.config.supportGuild%", client.config.supportGuild); + const embed = new Discord.MessageEmbed() - .setTitle(`Found a bug with ${client.user.username}?\nDM the core developer:`) + .setTitle(message.bugTitle) .setColor(client.config.embedColor) - .setDescription(`${client.developers}\nOr join the support server: ${client.config.supportGuild}`) + .setDescription(message.bugDescription) .setFooter('EximiaBots by Warén Media'); msg.channel.send(embed); + }, }; \ No newline at end of file diff --git a/commands/help.js b/commands/help.js index 7232b9e..325f94c 100644 --- a/commands/help.js +++ b/commands/help.js @@ -6,13 +6,22 @@ module.exports = { permission: 'none', category: 'info', execute(msg, args, client, Discord, prefix, command) { + let message = {}; + if (args[1]) { if (!client.commands.has(args[1]) || (client.commands.has(args[1]) && client.commands.get(args[1]).omitFromHelp === true)) return msg.channel.send('That command does not exist'); const command = client.commands.get(args[1]); + + message.helpCommandTitle = client.messages.helpCommandTitle.replace("%client.config.prefix%", client.config.prefix); + message.helpCommandTitle = message.helpCommandTitle.replace("%command.name%", command.name); + message.helpCommandTitle = message.helpCommandTitle.replace("%command.usage%", command.usage); + message.helpCommandDescription = client.messages.helpCommandTitle.replace("%command.description%", command.description); + message.helpCommandDescription = message.helpCommandDescription.replace("%command.alias%", command.alias); + const embed = new Discord.MessageEmbed() - .setTitle(`${client.global.db.guilds[msg.guild.id].prefix}${command.name} ${command.usage}`) + .setTitle(message.helpCommandTitle) .setColor(client.config.embedColor) - .setDescription(command.description + `\n Command Alias: \`${command.alias}\``) + .setDescription(message.helpCommandDescription) .setFooter('EximiaBots by Warén Media') msg.channel.send(embed); } else { @@ -24,10 +33,15 @@ module.exports = { for (let i = 0; i < categories.length; i++) { commands += `**» ${categories[i].toUpperCase()}**\n${client.commands.filter(x => x.category === categories[i] && !x.omitFromHelp).map(x => `\`${x.name}\``).join(', ')}\n`; } + + message.helpTitle = client.messages.helpTitle.replace("%client.user.username%", client.user.username); + message.helpDescription = client.messages.helpDescription.replace("%commands%", commands); + message.helpDescription = message.helpDescription.replace("%client.config.prefix%", client.config.prefix); + const embed = new Discord.MessageEmbed() - .setTitle(`${client.user.username} help:`) + .setTitle(message.helpTitle) .setColor(client.config.embedColor) - .setDescription(commands + `\n "${client.config.prefix}help " to see more information about a command.`) + .setDescription(message.helpDescription) .setFooter('EximiaBots by Warén Media'); msg.channel.send(embed); } diff --git a/commands/invite.js b/commands/invite.js index 15b898a..3934ca1 100644 --- a/commands/invite.js +++ b/commands/invite.js @@ -6,8 +6,10 @@ module.exports = { permission: 'none', category: 'info', execute(msg, args, client, Discord, prefix) { + let message = {}; + message.inviteTitle = client.messages.inviteTitle.replace("%client.user.username%", client.user.username); const embed = new Discord.MessageEmbed() - .setTitle(`Invite ${client.user.username} to your Discord server!`) + .setTitle(message.inviteTitle) .setColor(client.config.embedColor) .setURL(client.config.invite) .setFooter('EximiaBots by Warén Media'); diff --git a/commands/list.js b/commands/list.js index a9a1d2a..7f4b445 100644 --- a/commands/list.js +++ b/commands/list.js @@ -11,8 +11,9 @@ module.exports = { for (let i = 0; i < hashs; i++) { stations = stations.replace('**#**', `**${i + 1}**`); } + const embed = new Discord.MessageEmbed() - .setTitle(`Radio Stations`) + .setTitle(client.messages.listTitle) .setColor(client.config.embedColor) .setDescription(stations) .setFooter('EximiaBots by Warén Media') diff --git a/commands/nowplaying.js b/commands/nowplaying.js index 360a068..12a5309 100644 --- a/commands/nowplaying.js +++ b/commands/nowplaying.js @@ -6,15 +6,20 @@ module.exports = { permission: 'none', category: 'music', async execute(msg, args, client, Discord, prefix) { + let message = {}; const radio = client.radio.get(msg.guild.id); if (!radio || !radio.playing) return msg.channel.send('There is nothing playing.'); radio.time = radio.connection.dispatcher.streamTime; const completed = (radio.time.toFixed(0)); + message.nowplayingDescription = client.messages.nowplayingDescription.replace("%radio.station.name%", radio.station.name); + message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%", radio.station.owner); + message.nowplayingDescription = message.nowplayingDescription.replace("%msToTime(completed, \"hh:mm:ss\")%", msToTime(completed, "hh:mm:ss")); + const embed = new Discord.MessageEmbed() - .setTitle("Now Playing") + .setTitle(client.messages.nowplayingTitle) .setColor(client.config.embedColor) - .setDescription(`**${radio.station.name}** \n Owner: ${radio.station.owner} \n\`${msToTime(completed, "hh:mm:ss")}\``) + .setDescription(message.nowplayingDescription) .setFooter('EximiaBots by Warén Media'); return msg.channel.send(embed); } diff --git a/commands/play.js b/commands/play.js index 5e266cd..aca8039 100644 --- a/commands/play.js +++ b/commands/play.js @@ -10,17 +10,17 @@ module.exports = { const radio = client.radio.get(msg.guild.id); const voiceChannel = msg.member.voice.channel; if (!radio) { - if (!msg.member.voice.channel) return msg.channel.send('You need to be in a voice channel to play music!'); + if (!msg.member.voice.channel) return msg.channel.send(client.messages.noVoiceChannel); } else { - if (voiceChannel !== radio.voiceChannel) return msg.channel.send('You need to be in the same voice channel as RadioX to play music!'); + if (voiceChannel !== radio.voiceChannel) return msg.channel.send(client.messages.wrongVoiceChannel); } - if (!args[1]) return msg.channel.send('You need to use a number or search for a supported station!'); + if (!args[1]) return msg.channel.send(client.messages.noQuery); const permissions = voiceChannel.permissionsFor(msg.client.user); if (!permissions.has('CONNECT')) { - return msg.channel.send('I cannot connect to your voice channel.'); + return msg.channel.send(client.messages.noPermsConnect); } if (!permissions.has('SPEAK')) { - return msg.channel.send('I cannot speak in your voice channel.'); + return msg.channel.send(client.messages.noPermsSpeak); } let station; const number = parseInt(args[1] - 1); @@ -28,15 +28,15 @@ module.exports = { return; } else if (!isNaN(number)) { if (number > client.stations.length - 1) { - return msg.channel.send('No such station!'); + return msg.channel.send(client.messages.wrongStationNumber); } else { url = client.stations[number].stream[client.stations[number].stream.default]; station = client.stations[number]; } } else { - if (args[1].length < 3) return msg.channel.send('Station must be over 2 characters!'); + if (args[1].length < 3) return msg.channel.send(client.messages.tooShortSearch); const sstation = await searchStation(args.slice(1).join(' '), client); - if (!sstation) return msg.channel.send('No stations found!'); + if (!sstation) return msg.channel.send(client.messages.noSearchResults); url = sstation.stream[sstation.stream.default]; station = sstation } @@ -65,13 +65,12 @@ module.exports = { play(msg.guild, client, url); } catch (error) { client.radio.delete(msg.guild.id); - client.debug_channel.send("Error with connecting to voice channel: " + error); return msg.channel.send(`An error occured: ${error}`); } } }; function play(guild, client, url) { - + let message = {}; const radio = client.radio.get(guild.id); const dispatcher = radio.connection @@ -90,12 +89,13 @@ function play(guild, client, url) { console.error(error); radio.voiceChannel.leave(); client.radio.delete(guild.id); - return radio.textChannel.send('An error has occured while playing radio!'); + return radio.textChannel.send(client.messages.errorPlaying); }); dispatcher.setVolume(radio.volume / 10); - radio.textChannel.send(`Start playing: ${radio.station.name}`); + message.play = client.messages.play.replace("%radio.station.name%", radio.station.name); + radio.textChannel.send(message.play); radio.playing = true; }; diff --git a/commands/stop.js b/commands/stop.js index 4192c9a..1b486fb 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -11,7 +11,7 @@ module.exports = { radio.connection.dispatcher.destroy(); radio.voiceChannel.leave(); client.radio.delete(msg.guild.id); - msg.channel.send('Stopped playback!'); + msg.channel.send(client.messages.stop); } } }; \ No newline at end of file diff --git a/commands/volume.js b/commands/volume.js index 572b3aa..12763e0 100644 --- a/commands/volume.js +++ b/commands/volume.js @@ -6,16 +6,19 @@ module.exports = { permission: 'MANAGE_MESSAGES', category: 'music', execute(msg, args, client, Discord, prefix, command) { + let message = {}; const radio = client.radio.get(msg.guild.id); - if (!args[1] && radio) return msg.channel.send(`Current volume: **${radio.volume}**`); + /*message.currentVolume = client.messages.currentVolume.replace("%radio.volume%", radio.volume)*/ + if (!args[1] && radio) return msg.channel.send(client.messages.currentVolume); const volume = parseFloat(args[1]); if (client.funcs.check(client, msg, command)) { - if (isNaN(volume)) return msg.channel.send('you need to enter a valid __number__.'); - if (volume > 100) return msg.channel.send('The max volume is `100`!'); - if (volume < 0) return msg.channel.send('The volume needs to be a positive number!'); + if (isNaN(volume)) return msg.channel.send(client.messages.invalidVolume); + if (volume > 100) return msg.channel.send(client.messages.maxVolume); + if (volume < 0) return msg.channel.send(client.messages.negativeVolume); radio.volume = volume; radio.connection.dispatcher.setVolume(volume / 5); - return msg.channel.send(`Volume is now: **${volume}**`); + message.newVolume = client.messages.newVolume.replace("%volume%", volume); + return msg.channel.send(message.newVolume); } } }; diff --git a/struct/config.js b/config.js similarity index 90% rename from struct/config.js rename to config.js index 8ff5db0..2491b71 100644 --- a/struct/config.js +++ b/config.js @@ -4,6 +4,7 @@ module.exports = { //credentials token: process.env.DISCORD_TOKEN, + //support supportGuild: "https://discord.gg/rRA65Mn", devId: [ @@ -16,7 +17,7 @@ module.exports = { invite: "https://discordapp.com/api/oauth2/authorize?client_id=684109535312609409&permissions=3427328&scope=bot", //Settings - prefix: "rx>", + prefix: process.env.PREFIX || "rx>", volume: 5 } diff --git a/events/msg.js b/events/msg.js index 9b23a6f..afd4ec9 100644 --- a/events/msg.js +++ b/events/msg.js @@ -10,12 +10,12 @@ module.exports = { const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) || client.commandAliases.get(commandName); if (!command && msg.content !== `${prefix}`) return; const permissions = msg.channel.permissionsFor(msg.client.user); - if (!permissions.has('EMBED_LINKS')) return msg.channel.send('I cannot send embeds (Embed links).'); + if (!permissions.has('EMBED_LINKS')) return msg.channel.send(client.messages.noPermsEmbed); try { command.uses++; command.execute(msg, args, client, Discord, prefix, command); } catch (error) { - msg.reply(`Error!`); + msg.reply(client.messages.runningCommandFailed); console.error(error); } } diff --git a/events/voiceStateUpdate.js b/events/voiceStateUpdate.js index 7a0065a..d49292f 100644 --- a/events/voiceStateUpdate.js +++ b/events/voiceStateUpdate.js @@ -23,8 +23,7 @@ module.exports = { radio.connection.dispatcher.destroy(); radio.voiceChannel.leave(); client.radio.delete(msg.guild.id); - client.debug_channel.send("Error with connecting to voice channel: " + error); - return msg.channel.send(`An error occured: ${error}`); + return; } } if (newState.channel !== radio.voiceChannel) { diff --git a/struct/check.js b/struct/check.js index 7677574..6d6b78c 100644 --- a/struct/check.js +++ b/struct/check.js @@ -1,12 +1,11 @@ module.exports = function (client, msg, command) { const radio = client.radio.get(msg.guild.id); const permissions = msg.channel.permissionsFor(msg.author); - if (!radio || !radio.playing) return msg.channel.send('There is nothing playing!'); - if (msg.author.id !== client.config.devId) { - if (msg.member.voice.channel !== radio.voiceChannel) return msg.channel.send(`You need to be in the same voice channel as RadioX to use this command!`); - if (!permissions.has(command.permission)) { - msg.channel.send(`You need the \`${command.permission}\` permission to use this command!`); - return false; - } else return true; + if (!radio || !radio.playing) return msg.channel.send(client.messages.notPlaying); + if (msg.member.voice.channel !== radio.voiceChannel) return msg.channel.send(client.messages.wrongVoiceChannel); + if (!permissions.has(command.permission)) { + client.messages.noPerms = client.messages.noPerms.replace("%commands.permissions%", commands.permissions); + msg.channel.send(client.messages.noPerms); + return false; } else return true; }; diff --git a/struct/client.js b/struct/client.js index e4d021f..10d084c 100644 --- a/struct/client.js +++ b/struct/client.js @@ -15,8 +15,8 @@ module.exports = class extends Client { this.radio = new Map(); this.funcs = {}; this.dispatcher = {}; - this.config = require('./config.js'); - + this.config = require('../config.js'); + this.messages = require('./messages.js'); this.funcs.check = require('./check.js'); const commandFiles = fs.readdirSync(path.join(path.dirname(__dirname), 'commands')).filter(f => f.endsWith('.js')); diff --git a/struct/messages.js b/struct/messages.js new file mode 100644 index 0000000..ca95200 --- /dev/null +++ b/struct/messages.js @@ -0,0 +1,32 @@ +module.exports = { + wrongVoiceChannel: "You need to be in the same voice channel as RadioX to use this command!", + noPerms: "You need the %command.permission% permission to use this command!", + notPlaying: "There is nothing playing!", + runningCommandFailed: "Running this command failed!", + noPermsEmbed: "I cannot send embeds (Embed links).", + bugTitle: "Found a bug with %client.user.username%?\nDM one of the core developers:", + bugDescription: "%client.developers%\nOr join the support server: %client.config.supportGuild%", + helpTitle: "%client.user.username% help:", + helpDescription: "%commands% \n %client.config.prefix%help to see more information about a command.", + helpCommandTitle: "%client.config.prefix%%command.name% %command.usage%", + helpCommandDescription: "%command.description% \n Command Alias: %command.alias%", + inviteTitle: "Invite %client.user.username% to your Discord server!", + listTitle: "Radio Stations", + nowplayingTitle: "Now Playing", + nowplayingDescription: "**%radio.station.name%** \n Owner: %radio.station.owner% \n %msToTime(completed, \"hh:mm:ss\")%", + noVoiceChannel: "You need to be in a voice channel to play music!", + noQuery: "You need to use a number or search for a supported station!", + noPermsConnect: "I cannot connect to your voice channel.", + noPermsSpeak: "I cannot speak in your voice channel.", + wrongStationNumber: "No such station!", + tooShortSearch: "Station must be over 2 characters!", + noSearchResults: "No stations found!", + errorPlaying: "An error has occured while playing radio!", + play: "Start playing: %radio.station.name%", + stop: "Stopped playback!", + currentVolume: "Current volume: **%radio.volume%**", + maxVolume: "The max volume is `100`!", + invalidVolume: "You need to enter a valid __number__.", + negativeVolume: "The volume needs to be a positive number!", + newVolume: "Volume is now: **%volume%**" +}; \ No newline at end of file