tokens -> config
This commit is contained in:
10
config.json
Executable file
10
config.json
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"botName": "greenhambot",
|
||||||
|
"d_token": "MjkyNzAxNjg2NjE3ODY2MjUx.DEfe6Q.ShdWRL77BYgfKlW_oFvUwaiAn5Q",
|
||||||
|
"adminID": "88301001169207296",
|
||||||
|
"prefix": "!",
|
||||||
|
"passes": 2,
|
||||||
|
"allowedSfxChannels": "bot|alttp-alerts",
|
||||||
|
"sfxVolume": 0.3,
|
||||||
|
"botChannel": "bot"
|
||||||
|
}
|
||||||
18
main.js
18
main.js
@@ -4,15 +4,15 @@ const { Client } = require('discord.js'),
|
|||||||
path = require('path'),
|
path = require('path'),
|
||||||
moment = require('moment'),
|
moment = require('moment'),
|
||||||
timers = require('./lib/timers.js'),
|
timers = require('./lib/timers.js'),
|
||||||
tokens = require('./tokens.json');
|
config = require('./config.json');
|
||||||
|
|
||||||
// Set up Discord client
|
// Set up Discord client
|
||||||
const client = new Client();
|
const client = new Client();
|
||||||
|
|
||||||
// Set up SFX
|
// Set up SFX
|
||||||
const sfxFilePath = path.join(__dirname, 'sfx');
|
const sfxFilePath = path.join(__dirname, 'sfx');
|
||||||
const allowedSfxChannels = new RegExp(tokens.allowedSfxChannels);
|
const allowedSfxChannels = new RegExp(config.allowedSfxChannels);
|
||||||
let playOptions = {volume: tokens.sfxVolume, passes: tokens.passes};
|
let playOptions = {volume: config.sfxVolume, passes: config.passes};
|
||||||
let playing = false;
|
let playing = false;
|
||||||
|
|
||||||
// Read in sfx directory, filenames are the commands
|
// Read in sfx directory, filenames are the commands
|
||||||
@@ -60,15 +60,15 @@ const commands = {
|
|||||||
})(sfxPath);
|
})(sfxPath);
|
||||||
},
|
},
|
||||||
'reboot': (msg) => {
|
'reboot': (msg) => {
|
||||||
if (msg.author.id == tokens.adminID) process.exit(); //Requires a node module like Forever to work.
|
if (msg.author.id == config.adminID) process.exit(); //Requires a node module like Forever to work.
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Wait for discord to be ready, handle messages
|
// Wait for discord to be ready, handle messages
|
||||||
client.on('ready', () => {
|
client.on('ready', () => {
|
||||||
console.log(`${tokens.botName} is connected and ready`);
|
console.log(`${config.botName} is connected and ready`);
|
||||||
|
|
||||||
let alertsChannel = client.channels.find('name', 'bot');
|
let botChannel = client.channels.find('name', config.botChannel);
|
||||||
|
|
||||||
// Test timer
|
// Test timer
|
||||||
/*let timeToBlazeIt = moment().hour(16).minute(20).second(0).valueOf();
|
/*let timeToBlazeIt = moment().hour(16).minute(20).second(0).valueOf();
|
||||||
@@ -78,11 +78,11 @@ client.on('ready', () => {
|
|||||||
alertsChannel.send(`You know what time it is. ${emoji}`);
|
alertsChannel.send(`You know what time it is. ${emoji}`);
|
||||||
});*/
|
});*/
|
||||||
}).on('message', msg => {
|
}).on('message', msg => {
|
||||||
if (!msg.content.startsWith(tokens.prefix)) return;
|
if (!msg.content.startsWith(config.prefix)) return;
|
||||||
let cmd = msg.content.toLowerCase().slice(tokens.prefix.length).split(' ')[0];
|
let cmd = msg.content.toLowerCase().slice(config.prefix.length).split(' ')[0];
|
||||||
if (commands.hasOwnProperty(cmd)) commands[cmd](msg);
|
if (commands.hasOwnProperty(cmd)) commands[cmd](msg);
|
||||||
});
|
});
|
||||||
client.login(tokens.d_token);
|
client.login(config.d_token);
|
||||||
|
|
||||||
function readSfxDirectory(path)
|
function readSfxDirectory(path)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user