[英]Embed command discord.js character limit
我正在发出一个命令来识别有角色的人,他会列出所有有这个角色的人,但是他最终超出了字符限制,因为有很多人有这个角色,我该怎么办?
const { RichEmbed } = require("discord.js");
exports.run = (bot, message, args) => {
let staff = bot.emojis.get("718580359704477766")
const embed = new RichEmbed()
.setColor("#91e0ff")
.setTitle(`${staff} **| Lista de Staffers do Server**`)
.setThumbnail(bot.user.displayAvatarURL)
.addField(`Equipes Staffers:`, `<a:red2:721546087701282898>・<@&718861978864582707> - (${message.guild.roles.get('718861978864582707').members.size} staffs)`)
.setFooter(`Atenciosamente - ${bot.user.username}`, bot.user.displayAvatarURL)
.setTimestamp()
message.channel.send(embed).then(async msg => {
await msg.react('721546087701282898')
const collector = msg.createReactionCollector((r, u) => (r.emoji.id === '721244453997641758', '721546087701282898', '721546088279965829', '721546088657584150', '721546089190260766', '721546089622405121', '721546089693446145' && u.id === message.author.id))
collector.on("collect", async r => {
r.remove(message.author)
switch (r.emoji.id) {
case '721546087701282898':
msg.reactions.forEach(r=>{ r.users.filter(u =>u === message.author).forEach(bot=>{ r.remove(bot) }) })
msg.edit(new RichEmbed()
.setColor("#91e0ff")
.setTitle(`**Lista de Registro:**`)
.addField(`Registros:`, msg.guild.roles.get('718861978864582707').members.map(m => `<@${m.id}>`).join(`\n`))
.setFooter(`Atenciosamente - ${bot.user.username}`, bot.user.displayAvatarURL)
.setTimestamp()
.setThumbnail(bot.user.displayAvatarURL)
)}
})
})
}
exports.help = {
name: "lista"
}
您可以使用这个简单trimString
function 来确保字符串少于 1024 个字符:
trimString = (str, max) => ((str.length > max) ? `${str.slice(0, max - 3)}...` : str);
trimString("hi, how are you today?", 10);//"hi, how..."
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.