converted some strings in template strings
replaced hardcoded channel fixed prettier precommit prettified bot.js
This commit is contained in:
parent
366de08922
commit
7868578a7b
3 changed files with 65 additions and 65 deletions
16
bot/bot.js
16
bot/bot.js
|
@ -9,14 +9,14 @@ let commands = {};
|
||||||
|
|
||||||
const bot = new Discord.Client();
|
const bot = new Discord.Client();
|
||||||
|
|
||||||
bot.on('ready', function () {
|
bot.on('ready', function() {
|
||||||
console.log('Logged in! Serving in ' + bot.guilds.array().length + ' servers');
|
console.log(`Logged in! Serving in ${bot.guilds.array().length} servers`);
|
||||||
require('./plugins.js').init();
|
require('./plugins.js').init();
|
||||||
console.log('type ' + botConfig.prefix + 'help in Discord for a commands list.');
|
console.log(`type ${botConfig.prefix}help in Discord for a commands list.`);
|
||||||
bot.user.setActivity(botConfig.prefix + 'tip');
|
bot.user.setActivity(botConfig.prefix + 'tip');
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.on('disconnected', function () {
|
bot.on('disconnected', function() {
|
||||||
console.log('Disconnected!');
|
console.log('Disconnected!');
|
||||||
process.exit(1); //exit node.js with an error
|
process.exit(1); //exit node.js with an error
|
||||||
});
|
});
|
||||||
|
@ -24,7 +24,7 @@ bot.on('disconnected', function () {
|
||||||
function checkMessageForCommand(msg) {
|
function checkMessageForCommand(msg) {
|
||||||
//check if message is a command
|
//check if message is a command
|
||||||
if (msg.author.id !== bot.user.id && msg.content.startsWith(botConfig.prefix)) {
|
if (msg.author.id !== bot.user.id && msg.content.startsWith(botConfig.prefix)) {
|
||||||
console.log('treating ' + msg.content + ' from ' + msg.author + ' as command');
|
console.log(`treating ${msg.content} from ${msg.author} as command`);
|
||||||
let cmdTxt = msg.content.split(' ')[0].substring(botConfig.prefix.length);
|
let cmdTxt = msg.content.split(' ')[0].substring(botConfig.prefix.length);
|
||||||
let suffix = msg.content.substring(cmdTxt.length + botConfig.prefix.length + 1); //add one for the ! and one for the space
|
let suffix = msg.content.substring(cmdTxt.length + botConfig.prefix.length + 1); //add one for the ! and one for the space
|
||||||
if (msg.isMentioned(bot.user)) {
|
if (msg.isMentioned(bot.user)) {
|
||||||
|
@ -64,21 +64,21 @@ function checkMessageForCommand(msg) {
|
||||||
|
|
||||||
bot.on('message', msg => checkMessageForCommand(msg));
|
bot.on('message', msg => checkMessageForCommand(msg));
|
||||||
|
|
||||||
exports.addCommand = function (commandName, commandObject) {
|
exports.addCommand = function(commandName, commandObject) {
|
||||||
try {
|
try {
|
||||||
commands[commandName] = commandObject;
|
commands[commandName] = commandObject;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
exports.addCustomFunc = function (customFunc) {
|
exports.addCustomFunc = function(customFunc) {
|
||||||
try {
|
try {
|
||||||
customFunc(bot);
|
customFunc(bot);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
exports.commandCount = function () {
|
exports.commandCount = function() {
|
||||||
return Object.keys(commands).length;
|
return Object.keys(commands).length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ function doBalance(message, tipper) {
|
||||||
if (err) {
|
if (err) {
|
||||||
message.reply('Error getting balance');
|
message.reply('Error getting balance');
|
||||||
} else {
|
} else {
|
||||||
message.reply('You have *' + balance + '* LBC');
|
message.reply(`You have *${balance}* LBC`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ function doDeposit(message, tipper) {
|
||||||
if (err) {
|
if (err) {
|
||||||
message.reply('Error getting deposit address');
|
message.reply('Error getting deposit address');
|
||||||
} else {
|
} else {
|
||||||
message.reply('Your address is ' + address);
|
message.reply(`Your address is ${address}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ function doTip(message, tipper, words) {
|
||||||
|
|
||||||
function doHelp(message) {
|
function doHelp(message) {
|
||||||
if (!inPrivateOrBotSandbox(message)) {
|
if (!inPrivateOrBotSandbox(message)) {
|
||||||
message.reply('Sent you help via DM! Please use <#369896313082478594> or DMs to talk to bots.');
|
message.reply(`Sent you help via DM! Please use <#${sandboxChannel}> or DMs to talk to bots.`);
|
||||||
}
|
}
|
||||||
message.author.send(`**!tip**
|
message.author.send(`**!tip**
|
||||||
balance: get your balance
|
balance: get your balance
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
"request": "^2.83.0"
|
"request": "^2.83.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prettier": "prettier --write bot/**/*.js --single-quote --print-width 240",
|
"prettier": "prettier --write '{bot,.}/**/*.{js,json}' --single-quote --print-width 240",
|
||||||
"build": "babel bot -d dist",
|
"build": "babel bot -d dist",
|
||||||
"prod": "babel bot -d dist & node dist/bot.js",
|
"prod": "babel bot -d dist & node dist/bot.js",
|
||||||
"lint": "prettier --write bot/**/*.js --single-quote --print-width 240",
|
"lint": "prettier --write '{bot,.}/**/*.{js,json}' --single-quote --print-width 240",
|
||||||
"precommit": "prettier --write bot/**/*.js --single-quote --print-width 240"
|
"precommit": "prettier --write '{bot,.}/**/*.{js,json}' --single-quote --print-width 240"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"prettier": "1.7.4"
|
"prettier": "1.7.4"
|
||||||
|
|
Loading…
Reference in a new issue