Skip to content

Commit

Permalink
clean up and update cscl cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
jvnipers committed Nov 3, 2024
1 parent b02130b commit d7491b3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 30 deletions.
19 changes: 9 additions & 10 deletions src/commands/CSCL/cscl-restart.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const {
} = require("discord.js");
const { exec } = require("child_process");
const axios = require("axios");
const wait = require("timers/promises").setTimeout;
require("dotenv").config();

const key = process.env.API_KEY;
Expand Down Expand Up @@ -46,27 +45,27 @@ module.exports = {
const server = {
"cscl-fkz-1": {
name: "CS:CL EU - FKZ 1 - VNL KZ 128t",
user: "cscl-fkz-1",
user: "fkz-1",
id: null,
},
"cscl-fkz-2": {
name: "CS:CL EU - FKZ 2 - VNL KZ 64t",
user: "cscl-fkz-2",
user: "fkz-2",
id: null,
},
"cscl-fkz-3": {
name: "CS:CL EU - FKZ 3 - KZTimer 128t",
user: "cscl-fkz-3",
user: "fkz-3",
id: null,
},
"cscl-fkz-4": {
name: "CS:CL NA - FKZ 1 - VNL KZ 128t",
user: "cscl-fkz-1",
user: "fkz-1",
id: 1,
},
"cscl-fkz-5": {
name: "CS:CL NA - FKZ 2 - VNL KZ 64t",
user: "cscl-fkz-2",
user: "fkz-2",
id: 2,
},
}[servers];
Expand All @@ -80,7 +79,7 @@ module.exports = {
}

const { name, user, id } = server;
const command = `sudo -iu ${user} /home/${user}/csgoserver restart`;
const command = `sudo -iu cscl-${user} /home/cscl-${user}/csgoserver restart`;

if (
!interaction.member.permissions.has(PermissionFlagsBits.Administrator) &&
Expand All @@ -103,7 +102,6 @@ module.exports = {
exec(command, async (error, stdout, stderr) => {
if (error) console.log(error);
});
await wait(3000);
embed.setDescription(`Restarted: ${name}`);
return await interaction.editReply({
embeds: [embed],
Expand All @@ -120,15 +118,16 @@ module.exports = {
const response = await axios.post(
url,
{
command: command,
user: user,
game: "cscl",
command: "restart",
},
{
headers: {
authorization: `Bearer ${key}`,
},
}
);
await wait(3000);
if (response.data.status === 200) {
embed.setDescription(`Restarted: ${name}`);
return await interaction.editReply({
Expand Down
19 changes: 9 additions & 10 deletions src/commands/CSCL/cscl-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const {
} = require("discord.js");
const { exec } = require("child_process");
const axios = require("axios");
const wait = require("timers/promises").setTimeout;
require("dotenv").config();

const key = process.env.API_KEY;
Expand Down Expand Up @@ -46,27 +45,27 @@ module.exports = {
const server = {
"cscl-fkz-1": {
name: "CS:CL FKZ 1 - VNL KZ 128t",
user: "cscl-fkz-1",
user: "fkz-1",
id: null,
},
"cscl-fkz-2": {
name: "CS:CL FKZ 2 - VNL KZ 64t",
user: "cscl-fkz-2",
user: "fkz-2",
id: null,
},
"cscl-fkz-3": {
name: "CS:CL FKZ 3 - KZTimer 128t",
user: "cscl-fkz-3",
user: "fkz-3",
id: null,
},
"cscl-fkz-4": {
name: "CS:CL NA - FKZ 1 - VNL KZ 128t",
user: "cscl-fkz-1",
user: "fkz-1",
id: 1,
},
"cscl-fkz-5": {
name: "CS:CL NA - FKZ 2 - VNL KZ 64t",
user: "cscl-fkz-2",
user: "fkz-2",
id: 2,
},
}[servers];
Expand All @@ -80,7 +79,7 @@ module.exports = {
}

const { name, user, id } = server;
const command = `sudo -iu ${user} /home/${user}/csgoserver start`;
const command = `sudo -iu cscl-${user} /home/cscl-${user}/csgoserver start`;

if (
!interaction.member.permissions.has(PermissionFlagsBits.Administrator) &&
Expand All @@ -103,7 +102,6 @@ module.exports = {
exec(command, async (error, stdout, stderr) => {
if (error) console.log(error);
});
await wait(3000);
embed.setDescription(`Started: ${name}`);
return await interaction.editReply({
embeds: [embed],
Expand All @@ -120,15 +118,16 @@ module.exports = {
const response = await axios.post(
url,
{
command: command,
user: user,
game: "cscl",
command: "start",
},
{
headers: {
authorization: `Bearer ${key}`,
},
}
);
await wait(3000);
if (response.data.status === 200) {
embed.setDescription(`Started: ${name}`);
return await interaction.editReply({
Expand Down
19 changes: 9 additions & 10 deletions src/commands/CSCL/cscl-stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const {
} = require("discord.js");
const { exec } = require("child_process");
const axios = require("axios");
const wait = require("timers/promises").setTimeout;
require("dotenv").config();

const key = process.env.API_KEY;
Expand Down Expand Up @@ -46,27 +45,27 @@ module.exports = {
const server = {
"cscl-fkz-1": {
name: "CS:CL FKZ 1 - VNL KZ 128t",
user: "cscl-fkz-1",
user: "fkz-1",
id: null,
},
"cscl-fkz-2": {
name: "CS:CL FKZ 2 - VNL KZ 64t",
user: "cscl-fkz-2",
user: "fkz-2",
id: null,
},
"cscl-fkz-3": {
name: "CS:CL FKZ 3 - KZTimer 128t",
user: "cscl-fkz-3",
user: "fkz-3",
id: null,
},
"cscl-fkz-4": {
name: "CS:CL NA - FKZ 1 - VNL KZ 128t",
user: "cscl-fkz-1",
user: "fkz-1",
id: 1,
},
"cscl-fkz-5": {
name: "CS:CL NA - FKZ 2 - VNL KZ 64t",
user: "cscl-fkz-2",
user: "fkz-2",
id: 2,
},
}[servers];
Expand All @@ -80,7 +79,7 @@ module.exports = {
}

const { name, user, id } = server;
const command = `sudo -iu ${user} /home/${user}/csgoserver stop`;
const command = `sudo -iu cscl-${user} /home/cscl-${user}/csgoserver stop`;

if (
!interaction.member.permissions.has(PermissionFlagsBits.Administrator) &&
Expand All @@ -103,7 +102,6 @@ module.exports = {
exec(command, async (error, stdout, stderr) => {
if (error) console.log(error);
});
await wait(3000);
embed.setDescription(`Stopped: ${name}`);
return await interaction.editReply({
embeds: [embed],
Expand All @@ -120,15 +118,16 @@ module.exports = {
const response = await axios.post(
url,
{
command: command,
user: user,
game: "cscl",
command: "stop",
},
{
headers: {
authorization: `Bearer ${key}`,
},
}
);
await wait(3000);
if (response.data.status === 200) {
embed.setDescription(`Stopped: ${name}`);
return await interaction.editReply({
Expand Down

0 comments on commit d7491b3

Please sign in to comment.