109 lines
4.0 KiB
JavaScript
109 lines
4.0 KiB
JavaScript
const { Embed } = require("discord.js");
|
||
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
|
||
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');
|
||
const { ActionRowBuilder, SelectMenuBuilder } = require('discord.js');
|
||
const moji = require('randmoji');
|
||
let end = "<=================================END===========================>"
|
||
|
||
module.exports = {
|
||
name: "destroy",
|
||
description: "Destroys your Container.",
|
||
|
||
run: async (client, interaction) => {
|
||
// 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!")
|
||
(async () => {
|
||
await interaction.update({ content: interaction.values[0] + " No action taken!", components: [] });
|
||
})();
|
||
return console.log(end)
|
||
})();
|
||
} else {
|
||
(async () => {
|
||
await interaction.update({ content: interaction.values[0] + " was selected, destroying the container, please wait...", components: [] });
|
||
})();
|
||
}
|
||
|
||
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")
|
||
|
||
}
|
||
|
||
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")) {
|
||
(async () => {
|
||
console.log("A container does not exist to destroy")
|
||
await interaction.editReply("A container does not currently exist to destroy.");
|
||
console.log(end)
|
||
})();
|
||
}
|
||
console.log('err =', err)
|
||
})
|
||
}
|
||
}
|
||
})
|
||
}
|
||
} |