From c15076f834113e0748971cdbafb3fcc1dcbb32ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 15 Mar 2020 03:30:15 +0200 Subject: [PATCH] Changes to branding, custom and fallback emojis. Fixed help command. --- commands/bug.js | 3 ++- commands/help.js | 8 +++++--- commands/invite.js | 3 ++- commands/list.js | 3 ++- commands/nowplaying.js | 3 ++- commands/play.js | 18 +++++++++--------- commands/stop.js | 2 +- events/ready.js | 2 ++ struct/check.js | 6 +++--- struct/emojis.js | 30 ++++++++++++++++++++++++++++++ 10 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 struct/emojis.js diff --git a/commands/bug.js b/commands/bug.js index bc4377e..7ee7a9e 100644 --- a/commands/bug.js +++ b/commands/bug.js @@ -14,9 +14,10 @@ module.exports = { const embed = new Discord.MessageEmbed() .setTitle(message.bugTitle) + .setThumbnail("https://cdn.discordapp.com/emojis/686296221433725076.png") .setColor(client.config.embedColor) .setDescription(message.bugDescription) - .setFooter('EximiaBots by Warén Media'); + .setFooter('EximiaBots by Warén Media', 'https://cdn.discordapp.com/emojis/687022937978568760.png'); msg.channel.send(embed); }, diff --git a/commands/help.js b/commands/help.js index 325f94c..d56e7ef 100644 --- a/commands/help.js +++ b/commands/help.js @@ -15,14 +15,15 @@ module.exports = { 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 = client.messages.helpCommandDescription.replace("%command.description%", command.description); message.helpCommandDescription = message.helpCommandDescription.replace("%command.alias%", command.alias); const embed = new Discord.MessageEmbed() .setTitle(message.helpCommandTitle) + .setThumbnail("https://cdn.discordapp.com/emojis/686296221433725076.png") .setColor(client.config.embedColor) .setDescription(message.helpCommandDescription) - .setFooter('EximiaBots by Warén Media') + .setFooter('EximiaBots by Warén Media', 'https://cdn.discordapp.com/emojis/687022937978568760.png'); msg.channel.send(embed); } else { const categories = []; @@ -40,9 +41,10 @@ module.exports = { const embed = new Discord.MessageEmbed() .setTitle(message.helpTitle) + .setThumbnail("https://cdn.discordapp.com/emojis/686296221433725076.png") .setColor(client.config.embedColor) .setDescription(message.helpDescription) - .setFooter('EximiaBots by Warén Media'); + .setFooter('EximiaBots by Warén Media', 'https://cdn.discordapp.com/emojis/687022937978568760.png'); msg.channel.send(embed); } } diff --git a/commands/invite.js b/commands/invite.js index 3934ca1..180e928 100644 --- a/commands/invite.js +++ b/commands/invite.js @@ -10,9 +10,10 @@ module.exports = { message.inviteTitle = client.messages.inviteTitle.replace("%client.user.username%", client.user.username); const embed = new Discord.MessageEmbed() .setTitle(message.inviteTitle) + .setThumbnail("https://cdn.discordapp.com/emojis/686296221433725076.png") .setColor(client.config.embedColor) .setURL(client.config.invite) - .setFooter('EximiaBots by Warén Media'); + .setFooter('EximiaBots by Warén Media', 'https://cdn.discordapp.com/emojis/687022937978568760.png'); return msg.channel.send(embed); } }; \ No newline at end of file diff --git a/commands/list.js b/commands/list.js index 7f4b445..aefb27d 100644 --- a/commands/list.js +++ b/commands/list.js @@ -14,9 +14,10 @@ module.exports = { const embed = new Discord.MessageEmbed() .setTitle(client.messages.listTitle) + .setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["list"].replace(/[^0-9]+/g, '')) .setColor(client.config.embedColor) .setDescription(stations) - .setFooter('EximiaBots by Warén Media') + .setFooter('EximiaBots by Warén Media', 'https://cdn.discordapp.com/emojis/687022937978568760.png'); return msg.channel.send(embed); } }; \ No newline at end of file diff --git a/commands/nowplaying.js b/commands/nowplaying.js index 12a5309..b6c5c2a 100644 --- a/commands/nowplaying.js +++ b/commands/nowplaying.js @@ -18,9 +18,10 @@ module.exports = { const embed = new Discord.MessageEmbed() .setTitle(client.messages.nowplayingTitle) + .setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["play"].replace(/[^0-9]+/g, '')) .setColor(client.config.embedColor) .setDescription(message.nowplayingDescription) - .setFooter('EximiaBots by Warén Media'); + .setFooter('EximiaBots by Warén Media', 'https://cdn.discordapp.com/emojis/687022937978568760.png'); return msg.channel.send(embed); } }; diff --git a/commands/play.js b/commands/play.js index aca8039..bd4398c 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(client.messages.noVoiceChannel); + if (!msg.member.voice.channel) return msg.channel.send(client.messageEmojis["x"] + client.messages.noVoiceChannel); } else { - if (voiceChannel !== radio.voiceChannel) return msg.channel.send(client.messages.wrongVoiceChannel); + if (voiceChannel !== radio.voiceChannel) return msg.channel.send(client.messageEmojis["x"] + client.messages.wrongVoiceChannel); } 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(client.messages.noPermsConnect); + return msg.channel.send(client.messageEmojis["x"] + client.messages.noPermsConnect); } if (!permissions.has('SPEAK')) { - return msg.channel.send(client.messages.noPermsSpeak); + return msg.channel.send(client.messageEmojis["x"] + 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(client.messages.wrongStationNumber); + return msg.channel.send(client.messageEmojis["x"] + 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(client.messages.tooShortSearch); + if (args[1].length < 3) return msg.channel.send(client.messageEmojis["x"] + client.messages.tooShortSearch); const sstation = await searchStation(args.slice(1).join(' '), client); - if (!sstation) return msg.channel.send(client.messages.noSearchResults); + if (!sstation) return msg.channel.send(client.messageEmojis["x"] + client.messages.noSearchResults); url = sstation.stream[sstation.stream.default]; station = sstation } @@ -65,7 +65,7 @@ module.exports = { play(msg.guild, client, url); } catch (error) { client.radio.delete(msg.guild.id); - return msg.channel.send(`An error occured: ${error}`); + return msg.channel.send(client.messageEmojis["x"] + `An error occured: ${error}`); } } }; @@ -95,7 +95,7 @@ function play(guild, client, url) { dispatcher.setVolume(radio.volume / 10); message.play = client.messages.play.replace("%radio.station.name%", radio.station.name); - radio.textChannel.send(message.play); + radio.textChannel.send(client.messageEmojis["play"] + message.play); radio.playing = true; }; diff --git a/commands/stop.js b/commands/stop.js index 1b486fb..5abe8a9 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(client.messages.stop); + msg.channel.send(client.messageEmojis["stop"] + client.messages.stop); } } }; \ No newline at end of file diff --git a/events/ready.js b/events/ready.js index c17db55..8031f5d 100644 --- a/events/ready.js +++ b/events/ready.js @@ -31,5 +31,7 @@ module.exports = { client.stations = await fetch('https://gitea.cwinfo.org/cwchristerw/radio/raw/branch/master/playlist.json') .then(res => res.json()); }, 3600000); + + require(`../struct/emojis.js`).execute(client, Discord); } } \ No newline at end of file diff --git a/struct/check.js b/struct/check.js index dc634cf..fb4d404 100644 --- a/struct/check.js +++ b/struct/check.js @@ -3,16 +3,16 @@ 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){ - msg.channel.send(client.messages.notPlaying); + msg.channel.send(client.messageEmojis["x"] + client.messages.notPlaying); return false; } if (msg.member.voice.channel !== radio.voiceChannel){ - msg.channel.send(client.messages.wrongVoiceChannel); + msg.channel.send(client.messageEmojis["x"] + client.messages.wrongVoiceChannel); return false; } if (!permissions.has(command.permission)) { message.noPerms = client.messages.noPerms.replace("%commands.permissions%", commands.permissions); - msg.channel.send(message.noPerms); + msg.channel.send(client.messageEmojis["x"] + message.noPerms); return false; } else return true; }; diff --git a/struct/emojis.js b/struct/emojis.js new file mode 100644 index 0000000..d93d54f --- /dev/null +++ b/struct/emojis.js @@ -0,0 +1,30 @@ +module.exports = { + name: 'emojis', + async execute(client, Discord) { + let customEmojis = { + list: "<:RadioXList:688541155519889482>", + play: "<:RadioXPlay:688541155712827458>", + stop: "<:RadioXStop:688541155377414168>", + x: "<:RadioXX:688541155792781320>" + }; + + let fallbackEmojis = { + list: "📜", + play: "▶️", + stop: "⏹️", + x: "❌" + }; + + client.messageEmojis = {}; + + for(customEmojiName in customEmojis){ + customEmojiID = customEmojis[customEmojiName].replace(/[^0-9]+/g, ''); + customEmoji = client.emojis.cache.get(customEmojiID); + if(customEmoji){ + client.messageEmojis[customEmojiName] = customEmojis[customEmojiName]; + } else { + client.messageEmojis[customEmojiName] = fallbackEmojis[customEmojiName]; + } + } + } +} \ No newline at end of file