Initial removal of internal discord bot
This commit is contained in:
@@ -5,9 +5,7 @@ var cookieParser = require('cookie-parser');
|
||||
var logger = require('morgan');
|
||||
var http = require('http');
|
||||
require('dotenv').config();
|
||||
const fs = require('fs');
|
||||
const { DebugBuilder } = require("./utilities/debugBuilder");
|
||||
const deployCommands = require('./utilities/deployCommands');
|
||||
const { checkIn } = require("./controllers/clientController");
|
||||
|
||||
var indexRouter = require('./routes/index');
|
||||
@@ -16,28 +14,10 @@ var clientRouter = require('./routes/client');
|
||||
var radioRouter = require('./routes/radio');
|
||||
|
||||
const log = new DebugBuilder("client", "app");
|
||||
const {
|
||||
Client,
|
||||
Events,
|
||||
Collection,
|
||||
GatewayIntentBits,
|
||||
MessageActionRow,
|
||||
MessageButton
|
||||
} = require('discord.js');
|
||||
|
||||
var app = express();
|
||||
var discordToken = process.env.TOKEN;
|
||||
var port = process.env.HTTP_PORT || '3010';
|
||||
|
||||
const discordClient = new Client({
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
GatewayIntentBits.MessageContent,
|
||||
GatewayIntentBits.GuildVoiceStates
|
||||
]
|
||||
});
|
||||
|
||||
// view engine setup
|
||||
app.set('views', path.join(__dirname, 'views'));
|
||||
app.set('view engine', 'ejs');
|
||||
@@ -53,10 +33,7 @@ app.use(express.static(path.join(__dirname, 'public')));
|
||||
app.use('/', indexRouter);
|
||||
|
||||
// Discord bot control route
|
||||
app.use('/bot', (req, res, next) => {
|
||||
req.discordClient = discordClient; // Add the discord client to bot requests to be used downstream
|
||||
next();
|
||||
}, botRouter);
|
||||
app.use('/bot', botRouter);
|
||||
|
||||
// Local client control route
|
||||
app.use("/client", clientRouter);
|
||||
@@ -116,54 +93,8 @@ async function runHTTPServer() {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// Discord bot config
|
||||
|
||||
// Setup commands for the Discord bot
|
||||
discordClient.commands = new Collection();
|
||||
const commandsPath = path.join(__dirname, 'commands');
|
||||
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
||||
//const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
|
||||
for (const file of commandFiles) {
|
||||
const filePath = path.join(commandsPath, file);
|
||||
const command = require(filePath);
|
||||
log.DEBUG("Importing command: ", command.data.name);
|
||||
// Set a new item in the Collection
|
||||
// With the key as the command name and the value as the exported module
|
||||
discordClient.commands.set(command.data.name, command);
|
||||
}
|
||||
|
||||
// Run when the bot is ready
|
||||
discordClient.on('ready', () => {
|
||||
log.DEBUG(`Discord server up and running with client: ${discordClient.user.tag}`);
|
||||
log.INFO(`Logged in as ${discordClient.user.tag}!`);
|
||||
|
||||
// Deploy slash commands
|
||||
log.DEBUG("Deploying slash commands");
|
||||
deployCommands.deploy(discordClient.user.id, discordClient.guilds.cache.map(guild => guild.id));
|
||||
|
||||
log.DEBUG(`Starting HTTP Server`);
|
||||
log.DEBUG(`Starting HTTP Server`);
|
||||
runHTTPServer();
|
||||
|
||||
log.DEBUG("Checking in with the master server")
|
||||
checkIn();
|
||||
});
|
||||
|
||||
// Setup any additional event handlers
|
||||
const eventsPath = path.join(__dirname, 'events');
|
||||
if (fs.existsSync(eventsPath)) {
|
||||
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));
|
||||
if (eventFiles.length > 0) {
|
||||
for (const file of eventFiles) {
|
||||
const filePath = path.join(eventsPath, file);
|
||||
const event = require(filePath);
|
||||
if (event.once) {
|
||||
discordClient.once(event.name, (...args) => event.execute(...args));
|
||||
} else {
|
||||
discordClient.on(event.name, (...args) => event.execute(...args));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
discordClient.login(discordToken); //Load Client Discord Token
|
||||
Reference in New Issue
Block a user