discord-voice-recorder/index.js
Alex 509cadea67 update to d.js master and fix #17 (stage channels)
deleted the package-lock because i thought it would fix an npm issue which it didn't, shouldn't change anything though.  also added intents which are required in the new version of d.js
2021-05-03 01:59:02 -07:00

37 lines
1.1 KiB
JavaScript

const Discord = require('discord.js');
const client = new Discord.Client(
{intents: ["GUILD_MESSAGES", "GUILD_VOICE_STATES", "GUILDS"]}
);
const fs = require("fs");
const config = require('./config.json');
const commands = require(`./bin/commands`);
//in case the bot was not configured properly
if(!config.PREFIX || !config.BOT_TOKEN) {
console.error("Error: the configuration file was configured properly.");
console.error("Make sure there are no spelling mistakes.");
process.exit(1);
}
//create the recordings directory in case people forget to do so
try {
fs.mkdirSync("./recordings/");
} catch(ignored) {}
client.on('message', msg => {
if (msg.content.startsWith(config.PREFIX)) {
const commandBody = msg.content.substring(config.PREFIX.length).split(' ');
const channelName = commandBody[1];
if (commandBody[0] === ('enter') && commandBody[1]) commands.enter(msg, channelName);
if (commandBody[0] === ('exit')) commands.exit(msg);
}
});
client.login(config.BOT_TOKEN);
client.on('ready', () => {
console.log(`\nONLINE\n`);
});