standardize error messages

This commit is contained in:
bignutty 2024-12-26 23:17:46 +01:00
parent 295072d388
commit e523b5402e
4 changed files with 15 additions and 11 deletions

View file

@ -1,5 +1,5 @@
const { Permissions, MessageFlags } = require("detritus-client/lib/constants")
const { basecamp } = require("../logging")
const { basecamp, formatErrorMessage } = require("../logging")
const { COLORS, MESSAGE_BLOCK_REASONS } = require("#constants")
const { icon, link } = require("./markdown")
@ -28,7 +28,7 @@ module.exports.editOrReply = function(context, message, disableReference = false
if(context.editOrRespond){
if(context._meta?.replacementMessageId){
return context.editMessage(context._meta.replacementMessageId, message).catch((e)=>{
basecamp(`<:ico_w3:1086624963047460874>\`[${process.env.HOSTNAME}]\` **\` SHARD_MESSAGE_ERROR \`** \`[Shard ${context.client.shardId}]\` Command \`${context.command.name}\` failed to respond: @ \`${Date.now()}\`\nGuild: \`${context.guild?.id}\`\nChannel: \`${context.channel?.id}\`\nUser: \`${context.user?.id}\`\`\`\`js\n${e}\`\`\``, message)
basecamp(formatErrorMessage(3, "SHARD_MESSAGE_ERROR", `\`[Shard ${context.client.shardId}]\` Command \`${context.command.name}\` failed to respond:\nGuild: \`${context.guild?.id}\`\nChannel: \`${context.channel?.id}\`\nUser: \`${context.user?.id}\`\`\`\`js\n${e}\`\`\``), message);
});
}
@ -76,13 +76,13 @@ module.exports.editOrReply = function(context, message, disableReference = false
return replacementMessage;
}
basecamp(`<:ico_w3:1086624963047460874>\`[${process.env.HOSTNAME}]\` **\` SHARD_MESSAGE_ERROR \`** \`[Shard ${context.client.shardId}]\` Command \`${context.command.name}\` failed to respond: @ \`${Date.now()}\`\nGuild: \`${context.guild?.id}\`\nChannel: \`${context.channel?.id}\`\nUser: \`${context.user?.id}\`\`\`\`js\n${e}\`\`\``, message)
basecamp(formatErrorMessage(3, "SHARD_MESSAGE_ERROR", `\`[Shard ${context.client.shardId}]\` Command \`${context.command.name}\` failed to respond: @ \`${Date.now()}\`\nGuild: \`${context.guild?.id}\`\nChannel: \`${context.channel?.id}\`\nUser: \`${context.user?.id}\`\`\`\`js\n${e}\`\`\``), message);
})
}
// Only respond if the command is still available and we have permissions to respond.
if(!context.message.deleted && context.channel.can(Permissions.SEND_MESSAGES)) return context.editOrReply(message).catch((e)=>{
console.log(e.status)
basecamp(`<:ico_w3:1086624963047460874>\`[${process.env.HOSTNAME}]\` **\` SHARD_MESSAGE_ERROR \`** \`[Shard ${context.client.shardId}]\` Command \`${context.message?.content}\` failed to reply: @ \`${Date.now()}\`\nGuild: \`${context.guild?.id}\`\nChannel: \`${context.channel?.id}\`\nUser: \`${context.user?.id}\`\`\`\`js\n${e}\`\`\``, message)
basecamp(formatErrorMessage(3, "SHARD_MESSAGE_ERROR", `\`[Shard ${context.client.shardId}]\` Command \`${context.message?.content}\` failed to respond:\nGuild: \`${context.guild?.id}\`\nChannel: \`${context.channel?.id}\`\nUser: \`${context.user?.id}\`\`\`\`js\n${e}\`\`\``), message);
})
}