Skip to content

Commit

Permalink
function for returning error embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
12beesinatrenchcoat committed May 27, 2021
1 parent aa5a4f1 commit 02ba35a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions things.functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,23 @@ exports.sToDhms = function sToDhms(seconds, format = "str") {

exports.getLongMonth = function getLongMonth(month) {
return Intl.DateTimeFormat("en-US", { month: "long" }).format(month);
};

/**
* creates a MessageEmbed for response to a command error.
* @param {Message} message the message that triggered the command.
* @param {Object} error the error that occured.
* @param {String} error.title a title for the embed.
* @param {String} error.description description of the embed.
* @param {String} error.message message that goes along with the embed.
* @param {String} [descriptionOverride] override embed description with other text, if needed.
*/
const { MessageEmbed } = require("discord.js");
exports.returnError = function (message, error, descriptionOverride = undefined) {
const embed = new MessageEmbed()
.setTitle("error: " + error.title)
.setDescription(descriptionOverride ?? error.description)
.setColor("#FF0000");

return message.reply(error.message, embed);
};

0 comments on commit 02ba35a

Please sign in to comment.