Project Details slash command initial code
This commit is contained in:
parent
06241fb389
commit
2f50fdf0fd
11
package-lock.json
generated
11
package-lock.json
generated
@ -14,6 +14,7 @@
|
|||||||
"@sapphire/time-utilities": "^1.3.8",
|
"@sapphire/time-utilities": "^1.3.8",
|
||||||
"axios": "^0.25.0",
|
"axios": "^0.25.0",
|
||||||
"colorette": "^1.3.0",
|
"colorette": "^1.3.0",
|
||||||
|
"date-and-time": "^2.1.0",
|
||||||
"discord.js": "^13.0.1",
|
"discord.js": "^13.0.1",
|
||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
"enmap": "^5.8.5",
|
"enmap": "^5.8.5",
|
||||||
@ -720,6 +721,11 @@
|
|||||||
"node": ">=0.10"
|
"node": ">=0.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/date-and-time": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/date-and-time/-/date-and-time-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-X/b2gM7e8zQ7siiE0DhRLeNMpuCkIqec5Jnx4GMk/HWB71a6e5Lz48mH9/GIS/hpLsBRFZfMF1gjXBkY0vq5oA=="
|
||||||
|
},
|
||||||
"node_modules/debug": {
|
"node_modules/debug": {
|
||||||
"version": "4.3.2",
|
"version": "4.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
|
||||||
@ -4232,6 +4238,11 @@
|
|||||||
"assert-plus": "^1.0.0"
|
"assert-plus": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"date-and-time": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/date-and-time/-/date-and-time-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-X/b2gM7e8zQ7siiE0DhRLeNMpuCkIqec5Jnx4GMk/HWB71a6e5Lz48mH9/GIS/hpLsBRFZfMF1gjXBkY0vq5oA=="
|
||||||
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"version": "4.3.2",
|
"version": "4.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
"@sapphire/time-utilities": "^1.3.8",
|
"@sapphire/time-utilities": "^1.3.8",
|
||||||
"axios": "^0.25.0",
|
"axios": "^0.25.0",
|
||||||
"colorette": "^1.3.0",
|
"colorette": "^1.3.0",
|
||||||
|
"date-and-time": "^2.1.0",
|
||||||
"discord.js": "^13.0.1",
|
"discord.js": "^13.0.1",
|
||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
"enmap": "^5.8.5",
|
"enmap": "^5.8.5",
|
||||||
|
146
slash/getBoardDetails.js
Normal file
146
slash/getBoardDetails.js
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
// Import our needed HTTP Lib
|
||||||
|
var http = require('unirest');
|
||||||
|
const { MessageActionRow, MessageSelectMenu } = require('discord.js');
|
||||||
|
|
||||||
|
// Our main list array - STORAGE
|
||||||
|
let boardList=[]
|
||||||
|
let data
|
||||||
|
let desc
|
||||||
|
let columns = [];
|
||||||
|
|
||||||
|
//Requiring our discord components and paginator
|
||||||
|
const { MessageEmbed, MessageButton } = require("discord.js");
|
||||||
|
const { Pagination } = require("pagination.djs");
|
||||||
|
|
||||||
|
// Setting up our Global Config
|
||||||
|
require("dotenv").config();
|
||||||
|
|
||||||
|
// Grab RUN - get Client, interaction from the bot
|
||||||
|
exports.run = async (client, interaction) => {
|
||||||
|
|
||||||
|
|
||||||
|
// eslint-disable-line no-unused-vars
|
||||||
|
// Defer to aloow for embed building
|
||||||
|
await interaction.deferReply();
|
||||||
|
|
||||||
|
// 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 });
|
||||||
|
|
||||||
|
// Begin the request and send authenication using the jsonrpc2.0 protocol.
|
||||||
|
Request.auth({
|
||||||
|
user: 'jsonrpc',
|
||||||
|
pass: process.env.KANBOARD_API_KEY,
|
||||||
|
sendImmediately: false
|
||||||
|
}).then(function (response) {
|
||||||
|
|
||||||
|
// We have a response, lets set up a var
|
||||||
|
let data = response.body.result
|
||||||
|
|
||||||
|
// Setting up the correct formatting for our paginator
|
||||||
|
const pusherFunc = board=>boardList.push({label: board.name, description: board.name, value:board.id});
|
||||||
|
data.forEach(pusherFunc);
|
||||||
|
|
||||||
|
console.log(boardList)
|
||||||
|
const row = new MessageActionRow()
|
||||||
|
.addComponents(
|
||||||
|
new MessageSelectMenu()
|
||||||
|
.setCustomId('select')
|
||||||
|
.setPlaceholder('Select a Project')
|
||||||
|
.addOptions(boardList),
|
||||||
|
);
|
||||||
|
|
||||||
|
(async function(){
|
||||||
|
await interaction.editReply({ content: 'Use the menu below to choose a Project', components: [row] });
|
||||||
|
})()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// await interaction.reply({ content: 'Pong!', components: [row] });
|
||||||
|
client.on('interactionCreate', interaction => {
|
||||||
|
if (!interaction.isSelectMenu()) return;
|
||||||
|
|
||||||
|
if (interaction.customId === 'select') {
|
||||||
|
(async () => {
|
||||||
|
await interaction.update({ content: 'Selection Detected.', components: [] });
|
||||||
|
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]]});
|
||||||
|
|
||||||
|
// Begin the request and send authenication using the jsonrpc2.0 protocol.
|
||||||
|
Request.auth({
|
||||||
|
user: 'jsonrpc',
|
||||||
|
pass: process.env.KANBOARD_API_KEY,
|
||||||
|
sendImmediately: false
|
||||||
|
}).then(function (response) {
|
||||||
|
data = response.body.result[0]
|
||||||
|
console.log(data)
|
||||||
|
|
||||||
|
const date = require('date-and-time');
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
|
if (data.description == ''){
|
||||||
|
desc = "N/A"
|
||||||
|
} else {
|
||||||
|
desc = data.description
|
||||||
|
}
|
||||||
|
|
||||||
|
const pusherFunc = column=>columns.push(column.title + " Position: " + column.nb_tasks + " tasks.\n");
|
||||||
|
data.columns.forEach(pusherFunc);
|
||||||
|
|
||||||
|
const mainEmbed = new MessageEmbed()
|
||||||
|
.setColor('#0099ff')
|
||||||
|
.addFields(
|
||||||
|
{ name: 'Swimlane', value: data.name , inline: true },
|
||||||
|
{ name: 'Project ID', value: data.project_id , inline: true},
|
||||||
|
{ name: 'Description', value: desc },
|
||||||
|
{ name: 'Task Info', value: columns.join(" "), inline: true },
|
||||||
|
{ name: 'link', value: "https://" + process.env.ROOT_DOMAIN + "/board/" + data.project_id, inline: true }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
.setTitle('Requested Details')
|
||||||
|
.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 = {
|
||||||
|
name: "projectdetails",
|
||||||
|
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: true
|
||||||
|
};
|
@ -465,6 +465,11 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"assert-plus" "^1.0.0"
|
"assert-plus" "^1.0.0"
|
||||||
|
|
||||||
|
"date-and-time@^2.1.0":
|
||||||
|
"integrity" "sha512-X/b2gM7e8zQ7siiE0DhRLeNMpuCkIqec5Jnx4GMk/HWB71a6e5Lz48mH9/GIS/hpLsBRFZfMF1gjXBkY0vq5oA=="
|
||||||
|
"resolved" "https://registry.npmjs.org/date-and-time/-/date-and-time-2.1.0.tgz"
|
||||||
|
"version" "2.1.0"
|
||||||
|
|
||||||
"debug@^2.6.9":
|
"debug@^2.6.9":
|
||||||
"integrity" "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA=="
|
"integrity" "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA=="
|
||||||
"resolved" "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz"
|
"resolved" "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz"
|
||||||
|
Loading…
Reference in New Issue
Block a user