style: 🚨 Fix linter problem
All checks were successful
Publish staging Docker image / Push Docker image to Gitea Container Registry (push) Successful in 2m16s
All checks were successful
Publish staging Docker image / Push Docker image to Gitea Container Registry (push) Successful in 2m16s
This commit is contained in:
parent
437b6431d0
commit
1bfc619cc6
@ -6,7 +6,7 @@ if (!config.proxmoxUser || !config.proxmoxPass || !config.proxmoxHostname) {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
proxmox = require('proxmox')(config.proxmoxUser, config.proxmoxPass, config.proxmoxHostname);
|
const proxmox = require('proxmox')(config.proxmoxUser, config.proxmoxPass, config.proxmoxHostname);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
cooldowns: 60,
|
cooldowns: 60,
|
||||||
@ -25,46 +25,50 @@ module.exports = {
|
|||||||
|
|
||||||
const row = new ActionRowBuilder()
|
const row = new ActionRowBuilder()
|
||||||
.addComponents(cancel, confirm);
|
.addComponents(cancel, confirm);
|
||||||
const response = await interaction.reply({
|
const response = await interaction.reply({
|
||||||
content: 'Are you sure you want to start the Minecraft server?',
|
content: 'Are you sure you want to start the Minecraft server?',
|
||||||
components: [row]
|
components: [row],
|
||||||
})
|
});
|
||||||
// Before stop variable which return the time between now and 4am in discord timestamp
|
// Before stop variable which return the time between now and 4am in discord timestamp
|
||||||
const date = new Date(new Date().setDate(new Date().getDate() + 1))
|
const date = new Date(new Date().setDate(new Date().getDate() + 1));
|
||||||
date.setUTCHours(3, 0, 0, 0)
|
date.setUTCHours(3, 0, 0, 0);
|
||||||
const test = Math.round(date.getTime() / 1000);
|
const test = Math.round(date.getTime() / 1000);
|
||||||
const collectorFilter = i => i.user.id === interaction.user.id;
|
const collectorFilter = i => i.user.id === interaction.user.id;
|
||||||
let allowed = false;
|
let allowed = false;
|
||||||
for (const role of config.allowedRoles) {
|
for (const role of config.allowedRoles) {
|
||||||
if (interaction.member.roles.cache.has(role)) {
|
if (interaction.member.roles.cache.has(role)) {
|
||||||
allowed = true;
|
allowed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const confirmation = await response.awaitMessageComponent({ filter: collectorFilter, time: 30_000 });
|
const confirmation = await response.awaitMessageComponent({ filter: collectorFilter, time: 30_000 });
|
||||||
if (confirmation.customId === 'confirm') {
|
if (confirmation.customId === 'confirm') {
|
||||||
if (!allowed) {
|
if (!allowed) {
|
||||||
await confirmation.update({ content: 'You do not have permission to start the Minecraft server.', components: [] });
|
await confirmation.update({ content: 'You do not have permission to start the Minecraft server.', components: [] });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
proxmox.qemu.start("pve", "103", function(err) {
|
proxmox.qemu.start('pve', '103', function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
confirmation.update("Error starting the Minecraft server: " + err);
|
confirmation.update('Error starting the Minecraft server: ' + err);
|
||||||
} else {
|
}
|
||||||
const linkButton = new ButtonBuilder()
|
else {
|
||||||
.setStyle(ButtonStyle.Link)
|
const linkButton = new ButtonBuilder()
|
||||||
.setLabel('Web Interface')
|
.setStyle(ButtonStyle.Link)
|
||||||
.setURL('https://mc.louisgallet.fr')
|
.setLabel('Web Interface')
|
||||||
const row = new ActionRowBuilder()
|
.setURL('https://mc.louisgallet.fr');
|
||||||
.addComponents(linkButton)
|
const row2 = new ActionRowBuilder()
|
||||||
confirmation.update({content: "Minecraft server started successfully. Please wait a few minutes for it to boot. Use the command `/stop-mc` to stop it, otherwise, the server will be automatically shut down " + `<t:${test}:R>`, components: [row]});
|
.addComponents(linkButton);
|
||||||
}
|
confirmation.update({ content: 'Minecraft server started successfully. Please wait a few minutes for it to boot. Use the command `/stop-mc` to stop it, otherwise, the server will be automatically shut down ' + `<t:${test}:R>`, components: [row2] });
|
||||||
})
|
}
|
||||||
} else if (confirmation.customId === 'cancel') {
|
});
|
||||||
await confirmation.update({ content: 'Minecraft server start cancelled.', components: [] });
|
}
|
||||||
}
|
else if (confirmation.customId === 'cancel') {
|
||||||
} catch (e) {
|
await confirmation.update({ content: 'Minecraft server start cancelled.', components: [] });
|
||||||
await confirmation.update({ content: 'You took too long to respond.', components: [] });
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (e) {
|
||||||
}
|
// eslint-disable-next-line no-undef
|
||||||
|
await confirmation.update({ content: 'You took too long to respond.', components: [] });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
@ -8,16 +8,17 @@ if (!config.proxmoxUser || !config.proxmoxPass || !config.proxmoxHostname) {
|
|||||||
const proxmox = require('proxmox')(config.proxmoxUser, config.proxmoxPass, config.proxmoxHostname);
|
const proxmox = require('proxmox')(config.proxmoxUser, config.proxmoxPass, config.proxmoxHostname);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName('stop-mc')
|
.setName('stop-mc')
|
||||||
.setDescription('Stops the minecraft server machine.'),
|
.setDescription('Stops the minecraft server machine.'),
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
proxmox.qemu.shutdown("pve", "103", function(err, res) {
|
proxmox.qemu.shutdown('pve', '103', function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
interaction.reply("Error starting the Minecraft server: " + err);
|
interaction.reply('Error starting the Minecraft server: ' + err);
|
||||||
} else {
|
}
|
||||||
interaction.reply("Minecraft server stopped successfully.");
|
else {
|
||||||
}
|
interaction.reply('Minecraft server stopped successfully.');
|
||||||
})
|
}
|
||||||
}
|
});
|
||||||
}
|
},
|
||||||
|
};
|
@ -1,17 +1,17 @@
|
|||||||
const { SlashCommandBuilder } = require('discord.js')
|
const { SlashCommandBuilder } = require('discord.js');
|
||||||
const config = require('../../config.json')
|
const config = require('../../config.json');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName('check-perms')
|
.setName('check-perms')
|
||||||
.setDescription('Check if the user has the correct permissions to start the Minecraft server.'),
|
.setDescription('Check if the user has the correct permissions to start the Minecraft server.'),
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
for (const role of config.allowedRoles) {
|
for (const role of config.allowedRoles) {
|
||||||
if (interaction.member.roles.cache.has(role)) {
|
if (interaction.member.roles.cache.has(role)) {
|
||||||
await interaction.reply({ content: 'You have the correct permissions to start the Minecraft server.', ephemeral: true });
|
await interaction.reply({ content: 'You have the correct permissions to start the Minecraft server.', ephemeral: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await interaction.reply({ content: 'You have the correct permissions to start the Minecraft server.', ephemeral: true });
|
await interaction.reply({ content: 'You have the correct permissions to start the Minecraft server.', ephemeral: true });
|
||||||
},
|
},
|
||||||
}
|
};
|
@ -1,13 +1,13 @@
|
|||||||
const { SlashCommandBuilder } = require('discord.js')
|
const { SlashCommandBuilder } = require('discord.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName('test-time')
|
.setName('test-time')
|
||||||
.setDescription('Test the time between now and 4am in discord timestamp'),
|
.setDescription('Test the time between now and 4am in discord timestamp'),
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
const date = new Date(new Date().setDate(new Date().getDate() + 1))
|
const date = new Date(new Date().setDate(new Date().getDate() + 1));
|
||||||
date.setUTCHours(3, 0, 0, 0)
|
date.setUTCHours(3, 0, 0, 0);
|
||||||
const test = Math.round(date.getTime() / 1000);
|
const test = Math.round(date.getTime() / 1000);
|
||||||
await interaction.reply({ content: `Time between now and 4am: <t:${test}:R>`}, {ephemeral: true});
|
await interaction.reply({ content: `Time between now and 4am: <t:${test}:R>` }, { ephemeral: true });
|
||||||
},
|
},
|
||||||
}
|
};
|
Loading…
x
Reference in New Issue
Block a user