Bug gix to reset boardList and columns arrays and beauty
This commit is contained in:
parent
2f50fdf0fd
commit
0749dba48e
@ -3,7 +3,7 @@ var http = require('unirest');
|
|||||||
const { MessageActionRow, MessageSelectMenu } = require('discord.js');
|
const { MessageActionRow, MessageSelectMenu } = require('discord.js');
|
||||||
|
|
||||||
// Our main list array - STORAGE
|
// Our main list array - STORAGE
|
||||||
let boardList=[]
|
let boardList = []
|
||||||
let data
|
let data
|
||||||
let desc
|
let desc
|
||||||
let columns = [];
|
let columns = [];
|
||||||
@ -18,7 +18,6 @@ require("dotenv").config();
|
|||||||
// Grab RUN - get Client, interaction from the bot
|
// Grab RUN - get Client, interaction from the bot
|
||||||
exports.run = async (client, interaction) => {
|
exports.run = async (client, interaction) => {
|
||||||
|
|
||||||
|
|
||||||
// eslint-disable-line no-unused-vars
|
// eslint-disable-line no-unused-vars
|
||||||
// Defer to aloow for embed building
|
// Defer to aloow for embed building
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
@ -26,7 +25,7 @@ exports.run = async (client, interaction) => {
|
|||||||
// Setting up our Request, using getAllProjects method
|
// Setting up our Request, using getAllProjects method
|
||||||
var Request = http.get('https://' + process.env.ROOT_DOMAIN + '/jsonrpc.php').headers({ Accept: 'application/json', 'Content-Type': 'application/json' }).send({ "jsonrpc": "2.0", "method": "getAllProjects", "id": 0 });
|
var Request = http.get('https://' + process.env.ROOT_DOMAIN + '/jsonrpc.php').headers({ Accept: 'application/json', 'Content-Type': 'application/json' }).send({ "jsonrpc": "2.0", "method": "getAllProjects", "id": 0 });
|
||||||
|
|
||||||
// Begin the request and send authenication using the jsonrpc2.0 protocol.
|
// Begin the request and send authenication using the jsonrpc2.0 protocol.
|
||||||
Request.auth({
|
Request.auth({
|
||||||
user: 'jsonrpc',
|
user: 'jsonrpc',
|
||||||
pass: process.env.KANBOARD_API_KEY,
|
pass: process.env.KANBOARD_API_KEY,
|
||||||
@ -37,23 +36,21 @@ exports.run = async (client, interaction) => {
|
|||||||
let data = response.body.result
|
let data = response.body.result
|
||||||
|
|
||||||
// Setting up the correct formatting for our paginator
|
// Setting up the correct formatting for our paginator
|
||||||
const pusherFunc = board=>boardList.push({label: board.name, description: board.name, value:board.id});
|
const pusherFunc = board => boardList.push({ label: board.name, description: board.name, value: board.id });
|
||||||
data.forEach(pusherFunc);
|
data.forEach(pusherFunc);
|
||||||
|
|
||||||
console.log(boardList)
|
console.log(boardList)
|
||||||
const row = new MessageActionRow()
|
const row = new MessageActionRow()
|
||||||
.addComponents(
|
.addComponents(
|
||||||
new MessageSelectMenu()
|
new MessageSelectMenu()
|
||||||
.setCustomId('select')
|
.setCustomId('select')
|
||||||
.setPlaceholder('Select a Project')
|
.setPlaceholder('Select a Project')
|
||||||
.addOptions(boardList),
|
.addOptions(boardList),
|
||||||
);
|
);
|
||||||
|
|
||||||
(async function(){
|
(async function () {
|
||||||
await interaction.editReply({ content: 'Use the menu below to choose a Project', components: [row] });
|
await interaction.editReply({ content: 'Use the menu below to choose a Project', components: [row] });
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// await interaction.reply({ content: 'Pong!', components: [row] });
|
// await interaction.reply({ content: 'Pong!', components: [row] });
|
||||||
client.on('interactionCreate', interaction => {
|
client.on('interactionCreate', interaction => {
|
||||||
@ -64,73 +61,59 @@ exports.run = async (client, interaction) => {
|
|||||||
await interaction.update({ content: 'Selection Detected.', components: [] });
|
await interaction.update({ content: 'Selection Detected.', components: [] });
|
||||||
console.log(interaction.values[0]);
|
console.log(interaction.values[0]);
|
||||||
|
|
||||||
var Request = http.get('https://board.grwh.work/jsonrpc.php').headers({ Accept: 'application/json', 'Content-Type': 'application/json' }).send({"jsonrpc": "2.0","method": "getBoard","id": 0,"params": [interaction.values[0]]});
|
var Request = http.get('https://board.grwh.work/jsonrpc.php').headers({ Accept: 'application/json', 'Content-Type': 'application/json' }).send({ "jsonrpc": "2.0", "method": "getBoard", "id": 0, "params": [interaction.values[0]] });
|
||||||
|
|
||||||
// Begin the request and send authenication using the jsonrpc2.0 protocol.
|
// Begin the request and send authenication using the jsonrpc2.0 protocol.
|
||||||
Request.auth({
|
Request.auth({
|
||||||
user: 'jsonrpc',
|
user: 'jsonrpc',
|
||||||
pass: process.env.KANBOARD_API_KEY,
|
pass: process.env.KANBOARD_API_KEY,
|
||||||
sendImmediately: false
|
sendImmediately: false
|
||||||
}).then(function (response) {
|
}).then(function (response) {
|
||||||
data = response.body.result[0]
|
data = response.body.result[0]
|
||||||
console.log(data)
|
console.log(data)
|
||||||
|
|
||||||
const date = require('date-and-time');
|
const date = require('date-and-time');
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
if (data.description == ''){
|
if (data.description == '') {
|
||||||
desc = "N/A"
|
desc = "N/A"
|
||||||
} else {
|
} else {
|
||||||
desc = data.description
|
desc = data.description
|
||||||
}
|
}
|
||||||
|
|
||||||
const pusherFunc = column=>columns.push(column.title + " Position: " + column.nb_tasks + " tasks.\n");
|
const pusherFunc = column => columns.push(column.title + " Position: " + column.nb_tasks + " tasks.\n");
|
||||||
data.columns.forEach(pusherFunc);
|
data.columns.forEach(pusherFunc);
|
||||||
|
|
||||||
const mainEmbed = new MessageEmbed()
|
const mainEmbed = new MessageEmbed()
|
||||||
.setColor('#0099ff')
|
.setColor('#0099ff')
|
||||||
.addFields(
|
.addFields(
|
||||||
{ name: 'Swimlane', value: data.name , inline: true },
|
{ name: 'Swimlane', value: data.name, inline: true },
|
||||||
{ name: 'Project ID', value: data.project_id , inline: true},
|
{ name: 'Project ID', value: data.project_id, inline: true },
|
||||||
{ name: 'Description', value: desc },
|
{ name: 'Description', value: desc },
|
||||||
{ name: 'Task Info', value: columns.join(" "), inline: true },
|
{ name: 'Task Info', value: columns.join(" "), inline: true },
|
||||||
{ name: 'link', value: "https://" + process.env.ROOT_DOMAIN + "/board/" + data.project_id, inline: true }
|
{ name: 'link', value: "https://" + process.env.ROOT_DOMAIN + "/board/" + data.project_id, inline: true })
|
||||||
|
.setTitle('Requested Details')
|
||||||
|
.setDescription("Position " + data.position)
|
||||||
|
.setFooter(date.format(now, 'MM/DD/YYYY hh:mm:ss'));
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
await interaction.editReply({ embeds: [mainEmbed] });
|
||||||
|
// Clear the list
|
||||||
|
boardList = [];
|
||||||
)
|
columns = [];
|
||||||
.setTitle('Requested Details')
|
desc = "";
|
||||||
.setDescription("Position " + data.position)
|
})();
|
||||||
|
})
|
||||||
// .setThumbnail("https://wiki.codingvm.codes/paomedia-small-n-flat-terminal.ico")
|
|
||||||
|
|
||||||
.setFooter(date.format(now, 'MM/DD/YYYY hh:mm:ss'));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
await interaction.editReply({ embeds: [mainEmbed] });
|
|
||||||
})();
|
|
||||||
|
|
||||||
})
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Clear the list
|
|
||||||
boardList = [];
|
|
||||||
desc = "";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exports.commandData = {
|
exports.commandData = {
|
||||||
name: "projectdetails",
|
name: "projectdetails",
|
||||||
description: "Lists all of the current projects",
|
description: "Lists all of the current projects",
|
||||||
|
Loading…
Reference in New Issue
Block a user