From d43760a86f8c91af8c81831c4167f510a3fa9a5f Mon Sep 17 00:00:00 2001 From: Neko Life Date: Tue, 11 May 2021 14:46:58 +0000 Subject: [PATCH] stringify FIX --- cmds/experiment/mydatabase.js | 2 +- cmds/moderation/mute.js | 4 +++- cmds/utility/mesemb.js | 8 ++++---- cmds/utility/mesinfo.js | 10 +++++----- cmds/utility/uinfo.js | 8 ++++---- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/cmds/experiment/mydatabase.js b/cmds/experiment/mydatabase.js index f87e599..7ba728e 100644 --- a/cmds/experiment/mydatabase.js +++ b/cmds/experiment/mydatabase.js @@ -21,7 +21,7 @@ module.exports = class mydatabase extends commando.Command { return errLog(e, msg, this.client); } let mes = `Fetched documents for ${msg.guild ? `server **${msg.guild.name}**` : `**${msg.author.tag}**`}`; - mes = `${mes}\`\`\`js\n${JSON.stringify(fetched).split(',"').join(',\n"').split(',{').join(',\n{').split("{\"").join("{\n\"").split("\"}").join("\"\n}")}\`\`\``; + mes = `${mes}\`\`\`js\n${JSON.stringify(fetched, null, 4)}\`\`\``; trySend(this.client, msg, mes); return ranLog(msg, "mydatabase", fetched); }); diff --git a/cmds/moderation/mute.js b/cmds/moderation/mute.js index f7fea52..b82c21c 100644 --- a/cmds/moderation/mute.js +++ b/cmds/moderation/mute.js @@ -116,8 +116,9 @@ module.exports = class mute extends commando.Command { } } } + let infractionToDoc; if (targetUser.length > 0) { - const infractionToDoc = { + infractionToDoc = { infraction: Math.max(infractionDoc?.map(r => r.infraction) + 1), by: targetUser, moderator: `**${msg.author.tag}** <@${msg.author.id}> (${msg.author.id})`, @@ -139,6 +140,7 @@ module.exports = class mute extends commando.Command { } } resultMsg += `Result:\`\`\`js\nUsers: ${targetUser.map(r => r?.tag).join(", ")}\nReason: ${reason}\nAt: ${invokedAt.toUTCString()}\nFor: ${timeForMessage === "Indefinite" ? timeForMessage : timeForMessage.join(" + ")}\nUntil: ${typeof untilDate !== "string" ? untilDate.toUTCString() : untilDate}\`\`\`\n`; + trySend(this.client, msg, JSON.stringify(infractionToDoc, null, 4)); return trySend(this.client, msg, resultMsg); } }; diff --git a/cmds/utility/mesemb.js b/cmds/utility/mesemb.js index a2b4ea2..c928ee6 100644 --- a/cmds/utility/mesemb.js +++ b/cmds/utility/mesemb.js @@ -1,7 +1,7 @@ 'use strict'; const commando = require("@iceprod/discord.js-commando"); -const { getChannelMessage, ranLog, errLog, noPerm } = require("../../resources/functions"); +const { getChannelMessage, ranLog, errLog, noPerm, trySend } = require("../../resources/functions"); module.exports = class mesemb extends commando.Command { constructor(client) { @@ -17,9 +17,9 @@ module.exports = class mesemb extends commando.Command { try { const message = await getChannelMessage(this.client,msg,args[0],args[1]); console.log(message.embeds); - const mesemb = '```js\n'+JSON.stringify(message.embeds).split(',"').join(',\n"').split(',{').join(',\n{').replace(/`/g,"\\`")+'```'; - const result = msg.channel.send({content:'Collected:'+mesemb,split:{maxLength:2000,char: ", " || ",\n" || ". " || ".\n" || "," || ".",append:',```',prepend:'```js\n'}}); - return ranLog(msg,'mesemb',await result.content); + const mesemb = '```js\n'+JSON.stringify(message.embeds, null, 4)+'```'; + const result = await trySend(this.client, msg, {content:'Collected:'+mesemb,split:{maxLength:2000,char: ", " || ",\n" || ". " || ".\n" || "," || ".",append:',```',prepend:'```js\n'}}); + return ranLog(msg,'mesemb',result.content); } catch (e) { noPerm(msg); return errLog(e, msg, this.client); diff --git a/cmds/utility/mesinfo.js b/cmds/utility/mesinfo.js index 0200beb..f79593b 100644 --- a/cmds/utility/mesinfo.js +++ b/cmds/utility/mesinfo.js @@ -21,13 +21,13 @@ module.exports = class mesinfo extends commando.Command { return trySend(this.client, msg, "No message with that ID <:catstareLife:794930503076675584>") } else { try { - const mesinfo = 'Collected:```js\n'+JSON.stringify(message).split(',"').join(',\n"').split(',{').join(',\n{').replace(/`/g,"\\`")+'```'; + const mesinfo = 'Collected:```js\n'+JSON.stringify(message, null, 4).replace(/`/g,"\\`")+'```'; const mentionJSON = message.mentions.toJSON(); - const sendMentionInfo = 'Mentions:```js\n'+JSON.stringify(mentionJSON).split(',"').join(',\n"').split(',{').join(',\n{')+'```'; - const Attachments = 'Attachments:```js\n'+JSON.stringify(message.attachments).split(',"').join(',\n"').split(',{').join(',\n{')+'```'; + const sendMentionInfo = 'Mentions:```js\n'+JSON.stringify(mentionJSON, null, 4)+'```'; + const Attachments = 'Attachments:```js\n'+JSON.stringify(message.attachments, null, 4)+'```'; const sendmesinfo = mesinfo+sendMentionInfo+Attachments; - const result1 = msg.channel.send({content:sendmesinfo,split:{maxLength:2000,char: ", " || ",\n" || ". " || ".\n" || "," || ".",append:',```',prepend:'```js\n'}}); - return ranLog(msg,'mesinfo',`${await result1}`); + const result1 = await trySend(this.client, msg, {content:sendmesinfo,split:{maxLength:2000,char: ", " || ",\n" || ". " || ".\n" || "," || ".",append:',```',prepend:'```js\n'}}); + return ranLog(msg,'mesinfo',`${result1}`); } catch (e) { noPerm(msg); return errLog(e, msg, this.client, false, "", false, defaultErrorLogChannel); diff --git a/cmds/utility/uinfo.js b/cmds/utility/uinfo.js index 8797ea7..a123cd9 100644 --- a/cmds/utility/uinfo.js +++ b/cmds/utility/uinfo.js @@ -24,16 +24,16 @@ module.exports = class uinfo extends commando.Command { const member = msg.guild.member(profile); let result = 'User: '+profile.tag+'```js\n'; if (profile) { - result = result+JSON.stringify(profile).split(',"').join(',\n"').split(',{').join(',\n{')+'```'; + result = result+JSON.stringify(profile, null, 4)+'```'; } if (member) { - result = result+'As member: '+member.displayName+'```js\n'+JSON.stringify(member).split(',"').join(',\n"').split(',{').join(',\n{')+'```'; + result = result+'As member: '+member.displayName+'```js\n'+JSON.stringify(member, null, 4)+'```'; if ((member.displayColor)) { result = result+'Display color:```js\n'+member.displayColor+'```'; } } - trySend(this.client, msg, result,{split:{maxLength:2000,char: ", " || ",\n" || ". " || ".\n" || "," || ".",append:',```',prepend:'```js\n'}}); - return ranLog(msg,'profile',msg.content); + trySend(this.client, msg, result, {split:{maxLength:2000,char: ", " || ",\n" || ". " || ".\n" || "," || ".",append:',```',prepend:'```js\n'}}); + return ranLog(msg,'profile', msg.content); } catch (e) { return errLog(e, msg, this.client, false, 'Gimme the right ID!', true); }