diff --git a/commands.js b/commands.js index 70c3cb7..26ecc4f 100644 --- a/commands.js +++ b/commands.js @@ -1,3 +1,5 @@ +const { sendEmbedMessage } = require('./helpers.js'); + module.exports = { matchCommand: function (Discord, config, logger, message, command, args) { switch(command) { diff --git a/helpers.js b/helpers.js new file mode 100644 index 0000000..19acdcf --- /dev/null +++ b/helpers.js @@ -0,0 +1,19 @@ +module.exports = { + sendEmbedMessage: function (Discord, logger, message, title, description, colour = '#F4B400') { + // For documentation see https://github.com/AnIdiotsGuide/discordjs-bot-guide/blob/master/first-bot/using-embeds-in-messages.md + try { + const embed = new Discord.MessageEmbed() + .setTitle(title) + .setColor(colour) + .setDescription(description) + .setFooter('This is a community-made open source bot - if it goes down, fix it') + .setThumbnail('https://cdn.discordapp.com/icons/333376110329069578/b5cf0e90b74a3e1b828c15a262b7a5c8.png?size=128') + .setTimestamp(); + + message.channel.send(embed); + } catch (error) { + logger.error('Failed to send embed message', error); + message.channel.send('There was a problem, sorry!'); + } + }, +};