簡體   English   中英

分頁幫助命令 Discord.js v12

[英]Pagination help command Discord.js v12

如何使用此代碼進行分頁? 我不知道該怎么做。

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 和下面的命令,右邊的 4fun 和命令

您可以自己創建它,但是使用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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM