Compare commits
3 Commits
959cfdf7af
...
c9890c7cc8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9890c7cc8 | ||
|
|
bec4c2d743 | ||
|
|
45258d5e4b |
37
Server/commands/start-record.js
Normal file
37
Server/commands/start-record.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
const { SlashCommandBuilder } = require('discord.js');
|
||||||
|
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||||
|
const log = new DebugBuilder("server", "start-record");
|
||||||
|
const { getAllConnections } = require("../utilities/mysqlHandler");
|
||||||
|
const { requestOptions, sendHttpRequest } = require("../utilities/httpRequests");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('start-record')
|
||||||
|
.setDescription('Starts recording all bots online'),
|
||||||
|
example: "start-record",
|
||||||
|
isPrivileged: false,
|
||||||
|
requiresTokens: false,
|
||||||
|
defaultTokenUsage: 0,
|
||||||
|
deferInitialReply: false,
|
||||||
|
async execute(interaction) {
|
||||||
|
try{
|
||||||
|
await interaction.reply(`Ok, ${interaction.member}. **Recording** will begin shorting.`);
|
||||||
|
// Get nodes online
|
||||||
|
getAllConnections((connections) => {
|
||||||
|
for (const connection of connections){
|
||||||
|
const reqOptions = new requestOptions("/bot/startRecording", "POST", connection.node.ip, connection.node.port);
|
||||||
|
sendHttpRequest(reqOptions, JSON.stringify({}), async (responseObj) => {
|
||||||
|
log.VERBOSE("Response Object from node: ", connection, responseObj);
|
||||||
|
if (!responseObj || !responseObj.statusCode == 202 || !responseObj.statusCode == 204) return false;
|
||||||
|
if (responseObj.statusCode >= 300) return log.ERROR(responseObj.body);
|
||||||
|
// Bot is recording
|
||||||
|
await interaction.channel.send(`**${connection.clientObject.name} is now recording**`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}catch(err){
|
||||||
|
log.ERROR(err)
|
||||||
|
//await interaction.reply(err.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
37
Server/commands/stop-record.js
Normal file
37
Server/commands/stop-record.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
const { SlashCommandBuilder } = require('discord.js');
|
||||||
|
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||||
|
const log = new DebugBuilder("server", "stop-record");
|
||||||
|
const { getAllConnections } = require("../utilities/mysqlHandler");
|
||||||
|
const { requestOptions, sendHttpRequest } = require("../utilities/httpRequests");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('stop-record')
|
||||||
|
.setDescription('Starts recording all bots online'),
|
||||||
|
example: "stop-record",
|
||||||
|
isPrivileged: false,
|
||||||
|
requiresTokens: false,
|
||||||
|
defaultTokenUsage: 0,
|
||||||
|
deferInitialReply: false,
|
||||||
|
async execute(interaction) {
|
||||||
|
try{
|
||||||
|
await interaction.reply(`Ok, ${interaction.member}. **Recording** will stop shorting.`);
|
||||||
|
// Get nodes online
|
||||||
|
getAllConnections((connections) => {
|
||||||
|
for (const connection of connections){
|
||||||
|
const reqOptions = new requestOptions("/bot/stopRecording", "POST", connection.node.ip, connection.node.port);
|
||||||
|
sendHttpRequest(reqOptions, JSON.stringify({}), async (responseObj) => {
|
||||||
|
log.VERBOSE("Response Object from node: ", connection, responseObj);
|
||||||
|
if (!responseObj || !responseObj.statusCode == 204) return false;
|
||||||
|
if (responseObj.statusCode >= 300) return log.ERROR(responseObj.body);
|
||||||
|
// Bot is recording
|
||||||
|
await interaction.channel.send(`**${connection.clientObject.name} has stopped recording**`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}catch(err){
|
||||||
|
log.ERROR(err)
|
||||||
|
//await interaction.reply(err.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -9,7 +9,7 @@ module.exports = {
|
|||||||
name: Events.InteractionCreate,
|
name: Events.InteractionCreate,
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
const command = interaction.client.commands.get(interaction.commandName);
|
const command = interaction.client.commands.get(interaction.commandName);
|
||||||
log.VERBOSE("Interaction for command: ", command);
|
log.VERBOSE("Interaction created for command: ", command);
|
||||||
|
|
||||||
// Execute autocomplete if the user is checking autocomplete
|
// Execute autocomplete if the user is checking autocomplete
|
||||||
if (interaction.isAutocomplete()) {
|
if (interaction.isAutocomplete()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user