summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'app.js')
-rw-r--r--app.js97
1 files changed, 47 insertions, 50 deletions
diff --git a/app.js b/app.js
index 1cc2b0c..688dfda 100644
--- a/app.js
+++ b/app.js
@@ -1,48 +1,46 @@
const Discord = require('discord.js');
+const client = new Discord.Client();
const config = require('./config.json');
-const bot = new Discord.Client();
const emoji = require('emoji-random');
-bot.on('ready', () => {
- console.log(`Started bot: ${bot.user.tag} (ID: ${bot.user.id})\nCurrently running on ${bot.guilds.size} server(s).`);
- bot.user.setActivity('with squeaky toy :D', {
+client.once('ready', () => {
+ console.log(`Started bot: ${client.user.tag} (ID: ${client.user.id})\nCurrently running on ${client.guilds.cache.size} server(s).`);
+ client.user.setActivity('with my squeaky toy :D', {
type: 'PLAYING'
});
});
-bot.on('error', console.error);
+client.on('error', console.error);
-bot.on('message', async msg => {
+client.on('message', async msg => {
const upTime = require('moment');
require('moment-duration-format');
- const duration = upTime.duration(bot.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
+ const duration = upTime.duration(client.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
- function prefixCheck() {
- if (msgContent.startsWith('c!')) {
- return true;
- }
- var msgContent = msg.content.toLowerCase();
+ function prefixCheck() { if (msg.content.startsWith(config.prefix)) return true; }
if (prefixCheck()) {
- console.log(msg.member.user.tag, 'says', msgContent, 'in #' + msg.channel.name);
+ console.log(msg.member.user.tag, 'says', msg.content.toLowerCase(), 'in #' + msg.channel.name);
+ var args = msg.content.slice(config.prefix.length).split(/ +/);
+ var cmd = args.shift().toLowerCase();
}
- if (command == 'ping' || command == 'ms') {
+ if (cmd == 'ping' || cmd == 'ms' || cmd == 'p') {
const t = Date.now();
msg.channel.send('plz wait..').then(m => {
m.edit(`** **`);
const n = Date.now();
- let emb = new Discord.RichEmbed()
- .setDescription(`bork! chesters's is \`${n - t}ms\`. heartbeat \`${bot.ping}ms\`.`)
- .setColor(0xFFE4BA);
+ let emb = new Discord.MessageEmbed()
+ .setDescription(`bork! chesters's is \`${n - t}ms\`. heartbeat \`${client.ws.ping}ms\`. ` + emoji.random())
+ .setColor(0xFFE4BA);
- msg.channel.send(RichEmbed = emb);
+ msg.channel.send(emb);
});
}
- if (command == 'say') {
+ if (cmd == 'say' || cmd == 's') {
if (msg.member.hasPermission('KICK_MEMBERS')) {
m = args.join(' ');
msg.channel.send(m);
@@ -50,52 +48,51 @@ bot.on('message', async msg => {
}
}
- if (command == 'leave') {
- if (msg.guild.voiceConnection) {
- msg.guild.voiceConnection.disconnect();
- msg.reply('succesfully left voice channel');
+ if (cmd == 'leave' || cmd == 'l') {
+ if (msg.guild.voice) {
+ msg.guild.voice.disconnect();
+ msg.reply('succesfully left voice channel ' + emoji.random());
} else {
- msg.reply('i\'m not in a voice channel' + emoji.random());
+ msg.reply('i\'m not in a voice channel ' + emoji.random());
}
}
- if (command == 'join') {
- if (!msg.guild.voiceConnection && msg.member.voiceChannel) {
- msg.member.voiceChannel.join();
- msg.reply('succesfully joined voice channel' + emoji.random());
- } else if (msg.guild.voiceConnection) {
- msg.reply('i\'m already in voice channel' + emoji.random());
- } else if (!msg.member.voiceChannel) {
- msg.reply('you\'re not in a voice channel' + emoji.random());
+ if (cmd == 'join' || cmd == 'j') {
+ if (!msg.guild.voice && msg.member.voice.channel) {
+ msg.member.voice.channel.join();
+ msg.reply('succesfully joined voice channel ' + emoji.random());
+ } else if (msg.guild.voice) {
+ msg.reply('i\'m already in voice channel ' + emoji.random());
+ } else if (!msg.member.voice.channel) {
+ msg.reply('you\'re not in a voice channel ' + emoji.random());
}
}
- if (command == 'reboot' | command == 'r') {
- msg.member.voiceChannel.join();
- msg.member.voiceChannel.leave();
- msg.reply('reboot finished lol' + emoji.random());
- }
-
if (msg.mentions.everyone) {
msg.react(':ArisaPing:695887537390223402');
}
- if (msg.content == 'dog' | msg.content == 'dogs' | msg.content == 'bark' | msg.content == 'bork' | msg.content == 'woof') {
+ if (msg.content == 'dog' || msg.content == 'dogs' || msg.content == 'bark' || msg.content == 'bork' || msg.content == 'woof' || msg.content == 'mutt') {
var borkNum = Math.floor((Math.random() * 3) + 1);
+ var specialBork = Math.floor((Math.random() * 10) + 1);
+ var specialBorkCheck = Math.floor((Math.random() * 10) + 1);
- if (borkNum == 1) {
- msg.reply('bork' + emoji.random());
- } else if (borkNum == 2) {
- msg.reply('bark' + emoji.random());
- } else if (borkNum == 3) {
- msg.reply('woof' + emoji.random());
+ if (specialBork == specialBorkCheck) {
+ msg.reply('you got the special bork, this was a 1 in 100 chance of getting ' + emoji.random());
+ } else {
+ if (borkNum == 1) {
+ msg.reply('bork ' + emoji.random());
+ } else if (borkNum == 2) {
+ msg.reply('bark ' + emoji.random());
+ } else if (borkNum == 3) {
+ msg.reply('woof ' + emoji.random());
+ }
}
}
- if (command == 'uptime' || command == 'ut') {
- msg.reply(duration + emoji.random());
+ if (cmd == 'uptime' || cmd == 'ut') {
+ msg.reply(duration + ' ' + emoji.random());
}
-})
+});
-// Get bot token
-bot.login(config['secret']) \ No newline at end of file
+client.login(config['secret']); \ No newline at end of file