So I am trying to make a mod log command for my bot, but once the first log gets over 2048 characters I get this error
UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
embed.description: Must be 2048 or fewer in length.
How can I make it so that when it does reach this limit, it will make a new embed?
Here is my code btw
const moment = require('moment')
const Time = moment().format('MMMM DD YYYY h:mm:ss a');
const warnModel = require('../../models/ModSchema');
module.exports = {
name: "logs",
category: "moderation",
usage: "logs <UserID>",
description: "Get the previous moderation logs for a user.",
execute: async(client, message, member, args) => {
var GetTime = new Date()
var CurrentTime = Time + " " + GetTime.getHours() + ":" + GetTime.getMinutes() + ":" + GetTime.getSeconds()
const mentionedMember = message.mentions.members.first() || message.guild.members.cache.get(args[0])
const warnDoc = await warnModel.findOne({
guildID: message.guild.id,
memberID: mentionedMember.id,
}).catch(err => console.log(err))
if (!warnDoc || !warnDoc.Warnings.length) {
return message.channel.send(new MessageEmbed()
.setDescription(`**?** No warnings were found for ${mentionedMember}`)
.setTimestamp(message.createdAt)
.setColor('e30505'))
}
const data = []
let i = 0; warnDoc.Warnings.length > i; i++
for (let i = 0; warnDoc.Warnings.length > i; i++) {
data.push(`**Case ${warnDoc.Case[i]}**`)
data.push(`**User:** ${mentionedMember.user.tag} (${mentionedMember.id})`)
data.push(`**Type:** ${warnDoc.Type[i]}`)
data.push(`**Reason:** ${warnDoc.Warnings[i]}`)
data.push(`**Moderator:** ${await message.client.users.fetch(warnDoc.Moderator[i]).catch(() => 'Deleted User')}`)
data.push(`**Date:** ${new Date(warnDoc.Date[i]).toLocaleDateString()} ${new Date(warnDoc.Date[i]).toLocaleTimeString()}
`)
}
const embed = {
description: data.join('
')
}
const warnAmount = warnDoc.Warnings.length
message.channel.send(`**${warnAmount} logs were found**`, {embed: embed})
}
}
question from:
https://stackoverflow.com/questions/65854745/splitting-an-embed-that-is-over-2048-characters 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…