【问题标题】:How can i send a Pagination-embed with a music list discord.js我如何发送带有音乐列表 discord.js 的分页嵌入
【发布时间】:2021-05-10 07:26:33
【问题描述】:

我想发送一个带有音乐列表的分页嵌入,因为它不发送的嵌入低于 1024 个字母。 我要发送多页(每页最多 4 首音乐)

对不起我的英语,我是法国人......

  console.log(_serverQueue.songs)
  let q = ``;
  for(var i = 1; i < _serverQueue.songs.length; i++) {
      q += `\n${i + 1}. **${_serverQueue.songs[i].title}**`;
  }
  let resp = [
      {name: `Now Playing`, value: _serverQueue.songs[0].title},
      {name: `Queue`, value: q},
  ];

  //Putting it all together
  const FieldsEmbed = new Pagination.FieldsEmbed()
  .setArray({word: `Queue`})
  .setAuthorizedUsers([message.author.id])
  .setChannel(message.channel)
  .setElementsPerPage(4)
  .setPageIndicator(true)
  .formatField('Playlist :', el => el.word)
  FieldsEmbed.embed
    .setColor('#008000')
    .setTitle('Playlist :')
    FieldsEmbed.build()
}

【问题讨论】:

    标签: list pagination discord.js embed


    【解决方案1】:

    根据https://www.npmjs.com/package/discord-paginationembed的文档

    我用评论解释了步骤

    const Discord = require('discord.js');
    const Pagination = require('discord-paginationembed');
    
    const songText = ["This is a long SongText", "That is Split up Over", "Multiple Sites", "End of Song"];
    // The Splitting can happen via Discord.Js Util Class, it has a Splitter
    
    const embeds = [];
     
    for (let i = 1; i <= 4; ++i)
      embeds.push(new Discord.MessageEmbed().setFooter('Page ' + i).setDescription(songText[i - 1]));
     // Create Embeds here with the Content and push them into the Array
    
    const myImage = message.author.displayAvatarURL();
     
    new Pagination.Embeds()
      .setArray(embeds)
      .setAuthorizedUsers([message.author.id])
      .setChannel(message.channel)
      .setPageIndicator(true)
      .setPage(1)
       // Methods below are for customizing all embeds
      .setImage(myImage)
      .setThumbnail(myImage)
      .setTitle('Test Title')
      .setDescription('Test Description')
      .setURL(myImage)
      .setColor(0xFF00AE)
      .build();
    

    【讨论】:

      猜你喜欢
      • 2021-09-18
      • 2021-07-23
      • 2022-08-04
      • 1970-01-01
      • 2020-09-23
      • 2020-11-04
      • 2022-06-29
      • 2020-10-17
      • 2020-10-09
      相关资源
      最近更新 更多