【问题标题】:Pagination help command Discord.js v12分页帮助命令 Discord.js v12
【发布时间】:2021-06-01 22:45:09
【问题描述】:

如何在这段代码中使用分页? 我不知道该怎么做。

const {MessageEmbed} = require("discord.js")
module.exports = {
    name: "help",
    description: "Pokazuje wszystkie komendy",
    usage: "[Command name]",
    cooldown: 5,
  
     run(msg, args) {
        const arg = args[0]
        const embed = new MessageEmbed()
        
      const { commands } = msg.client
      const data = []
      
        
      if (!args.length) {
          
          data.push(embed.setTitle("**Komendy:**"))
          data.push(embed.setDescription(commands.map((command) => command.name).join(`\n`)), true)
          data.push(embed.setFooter(
              `\nZastosowanie\`${PREFIX}help [command name]\` aby dostać info o komendzie!`))

          return msg.channel.send(data, {split: true})
          
        }

        //podane argumenty
        const name = args[0].toLowerCase()  
        const command = 
        commands.get(name) ||
        commands.find((c) => c.aliases && c.aliases.includes(name))
        if (!command) {
            return msg.reply("Zła komenda!")
        }
        data.push(embed.setDescription(`**Nazwa:** ${command.name} \n **Użycie:** ${PREFIX}${command.name} ${command.usage} \n **Cooldown:** ${command.cooldown || 3} second(s)`))



        msg.channel.send(data, { split:true })
    },
  }

没有分页,看起来很傻。 这些命令彼此下方,看起来不太好。 或者,这些命令可以彼此相邻。 比如左边的moderation和下面的command,右边的4fun and also commands

【问题讨论】:

    标签: javascript discord.js


    【解决方案1】:

    您可以自己创建它,但是使用像 discord.js-pagination 这样的模块会更容易

    使用他们的例子:

    const paginationEmbed = require('discord.js-pagination');
     
    // Footers arent needed, this is added by the module
    const { MessageEmbed } = require('discord.js');
    const embed1 = new MessageEmbed();
    const embed2 = new MessageEmbed();
    
    // Create an array of embeds
    pages = [
        embed1,
        embed2,
    ];
    
    // first 2 args are required
    paginationEmbed(msg, pages, emojiList, timeout);
    

    【讨论】:

      猜你喜欢
      • 2020-12-08
      • 2021-01-01
      • 2021-02-18
      • 1970-01-01
      • 2021-12-20
      • 2021-01-12
      • 2021-01-18
      • 2021-04-14
      • 2021-04-19
      相关资源
      最近更新 更多