2022-01-24 14:05:30 -05:00
// For HTTP Requests
var http = require ( 'unirest' ) ;
let boardList = [ ]
let embed = [ ]
let pages = [ ]
const { MessageEmbed , MessageButton } = require ( "discord.js" ) ;
const { Pagination } = require ( "pagination.djs" ) ;
require ( "dotenv" ) . config ( ) ;
exports . run = async ( client , interaction ) => {
const pagination = new Pagination ( interaction , {
firstEmoji : "⏮" , // First button emoji
prevEmoji : "◀️" , // Previous button emoji
nextEmoji : "▶️" , // Next button emoji
lastEmoji : "⏭" , // Last button emoji
2022-01-24 14:21:34 -05:00
limit : process . env . PER _PAGE , // number of entries per page
2022-01-24 14:05:30 -05:00
idle : 30000 , // idle time in ms before the pagination closes
ephemeral : false , // ephemeral reply
prevDescription : "" ,
postDescription : "" ,
buttonStyle : "SECONDARY" ,
loop : false , // loop through the pages
} ) ;
// eslint-disable-line no-unused-vars
await interaction . deferReply ( ) ;
// const reply = await interaction.editReply("Ping?");
// await interaction.editReply(`Pong! Latency is ${reply.createdTimestamp - interaction.createdTimestamp}ms. API Latency is ${Math.round(client.ws.ping)}ms.`);
var Request = http . get ( 'https://board.grwh.work/jsonrpc.php' ) . headers ( { Accept : 'application/json' , 'Content-Type' : 'application/json' } ) . send ( { "jsonrpc" : "2.0" , "method" : "getAllProjects" , "id" : 0 } ) ;
Request . auth ( {
user : 'jsonrpc' ,
pass : process . env . KANBOARD _API _KEY ,
sendImmediately : false
} ) . then ( function ( response ) {
let data = response . body . result
2022-01-24 14:21:34 -05:00
const pusherFunc = board => boardList . push ( { name : "Project Name" , value : board . name + "\nID: " + board . id + "\n" + "https://" + process . env . ROOT _DOMAIN + "/board/" + board . id } ) ;
2022-01-24 14:05:30 -05:00
data . forEach ( pusherFunc ) ;
console . log ( boardList )
pagination . setTitle ( "Project List" ) ;
pagination . setDescription ( "This is a list of all currently active projects." ) ;
pagination . setColor ( "#00ff00" ) ;
pagination . setFooter ( "Boards:" ) ;
pagination . setTimestamp ( ) ;
pagination . addFields ( boardList ) ;
pagination . paginateFields ( true ) ;
pagination . render ( ) ;
} )
} ;
exports . commandData = {
name : "list" ,
description : "Lists all of the current projects" ,
options : [ ] ,
defaultPermission : true ,
} ;
// Set guildOnly to true if you want it to be available on guilds only.
// Otherwise false is global.
exports . conf = {
permLevel : "User" ,
guildOnly : false
} ;