如何在此代码中使用分页? 我不知道该怎么做。
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 and commands下面,右边的4fun and also commands
答案 0 :(得分:0)
您可以自己创建它,但是使用像 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);