2022-12-07 13:56:22 -05:00
|
|
|
|
const { Embed } = require("discord.js");
|
2022-12-07 14:42:04 -05:00
|
|
|
|
require('dotenv').config()
|
|
|
|
|
var portastic = require('portastic');
|
|
|
|
|
var unirest = require('unirest');
|
|
|
|
|
let ram
|
|
|
|
|
let vram
|
|
|
|
|
let cpus
|
|
|
|
|
var generator = require('generate-password');
|
|
|
|
|
var moment = require('moment');
|
|
|
|
|
const jsonfile = require('jsonfile')
|
|
|
|
|
let banned = 0
|
2022-12-07 13:56:22 -05:00
|
|
|
|
const fs = require("fs");
|
|
|
|
|
const dateFormat = require("dateformat");
|
|
|
|
|
require('dotenv').config()
|
|
|
|
|
const cmd = require('cmd-promise')
|
|
|
|
|
var portastic = require('portastic');
|
|
|
|
|
const { EmbedBuilder } = require('discord.js');
|
2022-12-07 14:42:04 -05:00
|
|
|
|
const { ActionRowBuilder, SelectMenuBuilder } = require('discord.js');
|
|
|
|
|
const moji = require('randmoji');
|
2022-12-07 13:56:22 -05:00
|
|
|
|
let end = "<=================================END===========================>"
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
2022-12-07 14:42:04 -05:00
|
|
|
|
name: "destroy",
|
|
|
|
|
description: "Destroys your Container.",
|
2022-12-07 13:56:22 -05:00
|
|
|
|
|
|
|
|
|
run: async (client, interaction) => {
|
2022-12-07 14:42:04 -05:00
|
|
|
|
// await interaction.deferReply();
|
|
|
|
|
//await interaction.editReply(`Please wait... lets make sure this is what you want to do...`);
|
|
|
|
|
const row = new ActionRowBuilder()
|
|
|
|
|
.addComponents(
|
|
|
|
|
new SelectMenuBuilder()
|
|
|
|
|
.setCustomId('selectDestroy')
|
|
|
|
|
.setPlaceholder('To destroy or not destroy?')
|
|
|
|
|
.addOptions([
|
|
|
|
|
{
|
|
|
|
|
label: 'Destroy IT!',
|
|
|
|
|
description: 'Remove the container and ALL of its DATA!',
|
|
|
|
|
value: 'Destroy',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'No, please do not destroy my precious data.',
|
|
|
|
|
description: 'This will cancel the command',
|
|
|
|
|
value: 'Action Canceled.',
|
|
|
|
|
},
|
|
|
|
|
]),
|
|
|
|
|
);
|
|
|
|
|
await interaction.editReply({ content: 'Use the menu below to choose an action.', components: [row] });
|
|
|
|
|
let submitted = 0;
|
|
|
|
|
// await interaction.reply({ content: 'Pong!', components: [row] });
|
|
|
|
|
client.on('interactionCreate', interaction => {
|
|
|
|
|
if (submitted == 1) return
|
|
|
|
|
if (!interaction.isSelectMenu()) return;
|
|
|
|
|
|
|
|
|
|
if (interaction.customId === 'selectDestroy') {
|
|
|
|
|
|
|
|
|
|
if (interaction.values[0].includes("Canceled")) {
|
|
|
|
|
(async () => {
|
|
|
|
|
// await interaction.reply("OK! No action taken!")
|
2022-12-07 13:56:22 -05:00
|
|
|
|
(async () => {
|
2022-12-07 14:42:04 -05:00
|
|
|
|
await interaction.update({ content: interaction.values[0] + " No action taken!", components: [] });
|
2022-12-07 13:56:22 -05:00
|
|
|
|
})();
|
2022-12-07 14:42:04 -05:00
|
|
|
|
return console.log(end)
|
|
|
|
|
})();
|
|
|
|
|
} else {
|
2022-12-07 13:56:22 -05:00
|
|
|
|
(async () => {
|
2022-12-07 14:42:04 -05:00
|
|
|
|
await interaction.update({ content: interaction.values[0] + " was selected, destroying the container, please wait...", components: [] });
|
2022-12-07 13:56:22 -05:00
|
|
|
|
})();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 14:42:04 -05:00
|
|
|
|
if (interaction.values[0] == "Destroy") {
|
|
|
|
|
cmd('docker stop ' + interaction.user.id + " && docker rm " + interaction.user.id).then(out => {
|
|
|
|
|
console.log('out =', out)
|
|
|
|
|
const netConfig = '/home/opc/netcache/' + interaction.user.id + ".network"
|
|
|
|
|
try {
|
|
|
|
|
fs.unlinkSync(netConfig)
|
|
|
|
|
console.log("Network Config Removed!")
|
|
|
|
|
} catch(err) {
|
|
|
|
|
console.log("No Config to remove")
|
|
|
|
|
|
2022-12-07 13:56:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 14:42:04 -05:00
|
|
|
|
const date = require('date-and-time');
|
|
|
|
|
const now = new Date();
|
|
|
|
|
const embed = new EmbedBuilder()
|
|
|
|
|
.setTitle("🤯 The container was destroyed!")
|
|
|
|
|
.setDescription(`You may generate a new one if you would like using /generate at any time!`)
|
|
|
|
|
.setTimestamp()
|
|
|
|
|
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
|
|
|
|
|
(async () => {
|
|
|
|
|
submitted = 1
|
|
|
|
|
await interaction.editReply("");
|
|
|
|
|
await interaction.editReply({ embeds: [embed] });
|
|
|
|
|
console.log(end)
|
|
|
|
|
})();
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
if (err.toString().includes("such")) {
|
2022-12-07 13:56:22 -05:00
|
|
|
|
(async () => {
|
2022-12-07 14:42:04 -05:00
|
|
|
|
console.log("A container does not exist to destroy")
|
|
|
|
|
await interaction.editReply("A container does not currently exist to destroy.");
|
|
|
|
|
console.log(end)
|
2022-12-07 13:56:22 -05:00
|
|
|
|
})();
|
|
|
|
|
}
|
2022-12-07 14:42:04 -05:00
|
|
|
|
console.log('err =', err)
|
2022-12-07 13:56:22 -05:00
|
|
|
|
})
|
2022-12-07 14:42:04 -05:00
|
|
|
|
}
|
2022-12-07 13:56:22 -05:00
|
|
|
|
}
|
2022-12-07 14:42:04 -05:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|