问题描述
我试图让模块工作,无论我做什么命令似乎都不会执行,这是我的代码。我一直在查看文档,但它们似乎对我没有意义(我是 .net 开发人员。
据我所知,我需要从我的块中创建我的页面
const discord = require('discord.js');
const pagination = require('discord.js-pagination');
const { schedule } = require('../../data/largeTest.json');
module.exports = {
name: 'h',//.ping
cooldown: 5,description: 'Current Release Schedule',execute(message) {
async (bot,message,args) => {
const MAX_FIELDS = 5;
// iterate over the commands and create field objects
const fields = schedule.flatMap((e) => ({ // the max number of fields in embeds is 25
name: "Chapter " + e.Chapter + " Name: " + e.ChapterName,value: "Date: " + e.StartDate + " - " + e.EndDate,inline: false // changes the layout
}
));
// if there are more,you need to create chunks w/ max 25 fields
const chunks = chunkify(fields,MAX_FIELDS);
// an array of embeds used by `discord.js-pagination`
const pages = [];
const emojiList = ["⏪","⏩"];
chunks.forEach((chunk) => {
// create a new embed for each 25 fields
pages.push(
new discord.MessageEmbed()
.setColor('#fbaaa2')
.setTitle(' Reading Schedule')
.addFields(chunk),);
});
pagination(message,pages,emojiList);
}
},};
// helper function to slice arrays
function chunkify(arr,len) {
let chunks = [];
let i = 0;
let n = arr.length;
while (i < n) {
chunks.push(arr.slice(i,(i += len)));
}
return chunks;
}
这是我正在使用的 json 文件
{
"EnName": "The Girl Who Leapt Through Time","JpName": "時をかける少女","PurchaseLink": "https://bookwalker.jp/de6292f341-cdb7-426e-b683-9ade176eef39/","schedule": [
{
"Chapter": 1,"ChapterName": "理科教室の黒い影","StartDate": "2021-07-01","EndDate": "2021-07-07"
},{
"Chapter": 2,"ChapterName": "ラベンダーのかおり","StartDate": "2021-07-08","EndDate": "2021-07-14"
},{
"Chapter": 3,"ChapterName": "地鳴りと震動","StartDate": "2021-07-15","EndDate": "2021-07-21"
},.....
]
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)