Discord.js从消息中切片自定义表情符号

时间:2020-05-12 10:39:52

标签: bots discord slice discord.js emoji

我正在尝试发出一条命令,通过该命令我可以将服务器中的所有表情符号嵌入。我遇到的第一个错误是文本限制。 .setDescription()最多只能包含2048个字符,因此我尝试嵌入页面以查看具有100个以上表情符号的服务器的表情符号。 我在反应菜单中使用软件包 dislord-rm 。 我的代码是:

const rm = require("dislord-rm");

module.exports = {
  name: "serveremojis",
  description: "Lists aree the available emojis of the current server.",
  aliases: ["emojis"],
  category: "?info",
  cooldown: 10,
  run: async(client, message, args) => {
  const emoji = message.guild.emojis;
  if (!emoji.size) return message.channel.send("Server has no emojis")
  if(emoji.size < 100) {
    const embed = new Discord.RichEmbed()
  .setTitle("Emojis!")
  .setColor("#CF98FC")
  .setFooter(message.author.username, message.author.displayAvatarURL)
  .setTimestamp()
  .setDescription(emoji.map(e=>e.toString()).join(" "))
  message.channel.send(embed)
  console.log(emoji.size);

  } else if(emoji.size > 100) {
    const embed = new Discord.RichEmbed()
  .setTitle("Emojis!")
  .setColor("#CF98FC")
  .setFooter(message.author.username, message.author.displayAvatarURL)
  .setTimestamp()
  .setDescription(emoji.slice(0, 100).map(e=>e.toString()).join(" "));

    const embed3 = new Discord.RichEmbed()
  .setTitle("Emojis!")
  .setColor("#CF98FC")
  .setFooter(message.author.username, message.author.displayAvatarURL)
  .setTimestamp()
  .setDescription(emoji.slice(100).map(e=>e.toString()).join(" "));
    new rm.menu(
            message.channel,
            message.author.id,
            [
                embed,
                embed3
            ]
        )
  }

在此代码中,第一个条件(即 emoji.size <100 )工作正常,但第二个条件未发送任何消息,并且在控制台中也没有错误。 我尝试将 .slice()放置在代码emoji.slice(100).map(e=>e.toString()).join(" ")中的每个位置,但是在任何地方都无法使用。

0 个答案:

没有答案
相关问题