summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author8cy <[email protected]>2020-04-08 20:02:33 -0700
committer8cy <[email protected]>2020-04-08 20:02:33 -0700
commit419467085d42d47f270e5ee1dda8676134e66c41 (patch)
tree0da5c310931e8598a5e0bb881d9dbaeea28f42eb
parentfix uptime, v1.4.3 (diff)
downloads5nical-419467085d42d47f270e5ee1dda8676134e66c41.tar.xz
s5nical-419467085d42d47f270e5ee1dda8676134e66c41.zip
big changes, v1.5.0
- add utils - add fun commands - alter some commands - optimizations
-rw-r--r--app.js65
-rw-r--r--commands/abee.js5
-rw-r--r--commands/fart.js23
-rw-r--r--commands/itemshop.js25
-rw-r--r--commands/psycho.js5
-rw-r--r--commands/squeak.js6
-rw-r--r--commands/uhhhh.js6
-rw-r--r--commands/volume.js15
-rw-r--r--commands/wahoo.js6
-rw-r--r--utils/bot_voice_check.js7
-rw-r--r--utils/no_args.js7
-rw-r--r--utils/no_command.js7
-rw-r--r--utils/perms.js7
-rw-r--r--utils/voice_check_dialog.js11
14 files changed, 137 insertions, 58 deletions
diff --git a/app.js b/app.js
index aa90a17..9409ed7 100644
--- a/app.js
+++ b/app.js
@@ -5,12 +5,19 @@ const Discord = require('discord.js');
const config = require('./config.json');
const bot = new Discord.Client();
bot.commands = new Discord.Collection();
+bot.utils = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
bot.commands.set(command.name, command);
}
+const utilFiles = fs.readdirSync('./utils').filter(file => file.endsWith('.js'));
+for (const file of utilFiles) {
+ const util = require(`./utils/${file}`);
+
+ bot.utils.set(util.name, util);
+}
bot.on('ready', () => {
console.log(`Started bot: ${bot.user.tag} (ID: ${bot.user.id})\nCurrently running on ${bot.guilds.size} server(s).`); // Startup dialouge in output console
@@ -25,7 +32,8 @@ bot.on('message', async msg => {
//if (msg.channel.name === 'bots' || msg.channel.name === 'bot-commands' || msg.member.hasPermission('KICK_MEMBERS')) {
if (msg.author.bot) {
// Debugging to see if the bot has an influence on the commands having an error
- console.log('bot message picked up');
+ //console.log('bot message picked up');
+ return;
} else {
// Constants for uptime command
const upTime = require('moment');
@@ -37,7 +45,7 @@ bot.on('message', async msg => {
if (prefixCheck()) {
console.log(msg.member.user.tag, 'says', msgContent, 'in #' + msg.channel.name);
}
-
+
// Check if message has a prefix in it from config.json
function prefixCheck() {
if (msgContent.startsWith(config.prefixes.main)) {
@@ -58,32 +66,32 @@ bot.on('message', async msg => {
return "alt6b";
}
}
-
- if (prefixCheck() == "main") {
+
+ if (prefixCheck() == "main") {
var args = msg.content.slice(config.prefixes.main.length).split(/ +/);
var command = args.shift().toLowerCase();
- if (msg.author.bot || !msg.content.startsWith(config.prefixes.main)) return;
- } else if (prefixCheck() == "alt1") {
+ if (msg.author.bot || !msg.content.startsWith(config.prefixes.main)) return;
+ } else if (prefixCheck() == "alt1") {
var args = msg.content.slice(config.prefixes.alt.length).split(/ +/);
var command = args.shift().toLowerCase();
- if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt)) return;
- } else if (prefixCheck() == "alt2") {
+ if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt)) return;
+ } else if (prefixCheck() == "alt2") {
var args = msg.content.slice(config.prefixes.alt2.length).split(/ +/);
var command = args.shift().toLocaleLowerCase();
- if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt2)) return;
- } else if (prefixCheck() == "alt3") {
+ if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt2)) return;
+ } else if (prefixCheck() == "alt3") {
var args = msg.content.slice(config.prefixes.alt3.length).split(/ +/);
var command = args.shift().toLocaleLowerCase();
- if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt3)) return;
- } else if (prefixCheck() == "alt4") {
+ if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt3)) return;
+ } else if (prefixCheck() == "alt4") {
var args = msg.content.slice(config.prefixes.alt4.length).split(/ +/);
var command = args.shift().toLocaleLowerCase();
- if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4)) return;
+ if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4)) return;
} else if (prefixCheck() == "alt5") {
var args = msg.content.slice(config.prefixes.alt4.length).split(/ +/);
var command = args.shift().toLocaleLowerCase();
@@ -94,32 +102,16 @@ bot.on('message', async msg => {
var command = args.shift().toLocaleLowerCase();
if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4)) return;
- } else if (prefixCheck() == "alt6b") {
+ } else if (prefixCheck() == "alt6b") {
var args = msg.content.slice(config.prefixes.alt4b.length).split(/ +/);
var command = args.shift().toLocaleLowerCase();
- if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4b)) return;
+ if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4b)) return;
}
- // edge case arguments
- function noArgs() {
- msg.channel.send(`invalid argument(s). type \`${config.prefixes.main}help\` for more information.`);
- }
-
- function noCommand() {
- msg.channel.send(`invalid or unspecified command. type \`${config.prefixes.main}help\`.`);
- }
-
- function perms(p) {
- if (msg.member.hasPermission(p)) return true;
- }
-
- function connectionCheck() {
- if (msg.guild.voiceConnection) {
- msg.reply('i\'m already playing that lol');
- } else {
- msg.reply('you need to join a voice channel first silly');
- }
+ // Reacts with ping emoji when @everyone
+ if (msg.mentions.everyone) {
+ msg.react(':ArisaPing:695887537390223402');
}
// Cooldown check
@@ -137,11 +129,6 @@ bot.on('message', async msg => {
msg.reply('command error\'d out, check logs. also, how did u manage to break it lol');
return;
}
-
- // Reacts with ping emoji when @everyone
- if (msg.mentions.everyone) {
- msg.react(':ArisaPing:695887537390223402');
- }
//} else if (msg.channel.name !== 'bots' && msg.content.startsWith(`${config.prefixes.main}`) && !msg.member.hasPermission('KICK_MEMBERS')) return;
}
});
diff --git a/commands/abee.js b/commands/abee.js
index 3cde38b..ced7c10 100644
--- a/commands/abee.js
+++ b/commands/abee.js
@@ -1,4 +1,5 @@
const ytdl = require('ytdl-core');
+const voice_check_dialog = require('../utils/voice_check_dialog.js');
module.exports = {
name: 'abee',
@@ -17,10 +18,8 @@ module.exports = {
dispatcher.on('end', () => {
msg.member.voiceChannel.leave();
});
- } else if (msg.guild.voiceConnection) {
- msg.reply('i\'m already playing that lol');
} else {
- msg.reply('you need to join a voice channel first silly');
+ voice_check_dialog.execute(msg);
}
}
}; \ No newline at end of file
diff --git a/commands/fart.js b/commands/fart.js
index de62889..d2fbeb5 100644
--- a/commands/fart.js
+++ b/commands/fart.js
@@ -1,8 +1,25 @@
+const voice_check_dialog = require('../utils/voice_check_dialog.js');
+const bot_voice_check = require('../utils/bot_voice_check.js');
+
module.exports = {
name: 'fart',
+ aliases: ['f'],
description: '',
async execute(msg, args, bot) {
- if (msg.member.voiceChannel && !msg.guild.voiceConnection) {
+ if (args[0] == 'long' || args[0] == 'longest' || args[0] == 'l') {
+ if (msg.member.voiceChannel && !msg.guild.voiceConnection) {
+ const connection = await msg.member.voiceChannel.join();
+ const dispatcher = connection.playFile('./assets/audio/longest_fart_ever.mp3', {
+ volume: 1.0
+ });
+
+ dispatcher.on('end', () => {
+ msg.member.voiceChannel.leave();
+ });
+ } else {
+ voice_check_dialog.execute(msg);
+ }
+ } else if (msg.member.voiceChannel && !msg.guild.voiceConnection) {
const connection = await msg.member.voiceChannel.join();
var fartNum = Math.floor((Math.random() * 8) + 1);
@@ -71,10 +88,8 @@ module.exports = {
msg.member.voiceChannel.leave();
});
}
- } else if (msg.guild.voiceConnection) {
- msg.reply('i\'m already playing that lol');
} else {
- msg.reply('you need to join a voice channel first silly');
+ voice_check_dialog.execute(msg);
}
}
}; \ No newline at end of file
diff --git a/commands/itemshop.js b/commands/itemshop.js
new file mode 100644
index 0000000..838d4f4
--- /dev/null
+++ b/commands/itemshop.js
@@ -0,0 +1,25 @@
+const ytdl = require('ytdl-core');
+
+module.exports = {
+ name: 'itemshop',
+ description: '',
+ async execute(msg, args, bot) {
+ if (msg.member.voiceChannel && !msg.guild.voiceConnection) {
+ const connection = await msg.member.voiceChannel.join();
+ const stream = ytdl('https://www.youtube.com/watch?v=pBiI1hTwU7E', {
+ filter: 'audioonly'
+ });
+ const dispatcher = connection.playStream(stream, {
+ volume: 0.5
+ });
+
+ dispatcher.on('end', () => {
+ msg.member.voiceChannel.leave();
+ });
+ } else if (msg.guild.voiceConnection) {
+ msg.reply('i\'m already playing that lol');
+ } else {
+ msg.reply('you need to join a voice channel first silly');
+ }
+ }
+}; \ No newline at end of file
diff --git a/commands/psycho.js b/commands/psycho.js
index 9ecc8a1..13bca98 100644
--- a/commands/psycho.js
+++ b/commands/psycho.js
@@ -1,4 +1,5 @@
const ytdl = require('ytdl-core');
+const voice_check_dialog = require('../utils/voice_check_dialog.js');
module.exports = {
name: 'psycho',
@@ -16,10 +17,8 @@ module.exports = {
dispatcher.on('end', () => {
msg.member.voiceChannel.leave();
});
- } else if (msg.guild.voiceConnection) {
- msg.reply('i\'m already playing that lol');
} else {
- msg.reply('you need to join a voice channel first silly');
+ voice_check_dialog.execute(msg);
}
}
}; \ No newline at end of file
diff --git a/commands/squeak.js b/commands/squeak.js
index a1c4046..fef4520 100644
--- a/commands/squeak.js
+++ b/commands/squeak.js
@@ -1,3 +1,5 @@
+const voice_check_dialog = require('../utils/voice_check_dialog.js');
+
module.exports = {
name: 'squeak',
description: '',
@@ -11,10 +13,8 @@ module.exports = {
dispatcher.on('end', () => {
msg.member.voiceChannel.leave();
});
- } else if (msg.guild.voiceConnection) {
- msg.reply('i\'m already playing that lol');
} else {
- msg.reply('you need to join a voice channel first silly');
+ voice_check_dialog.execute(msg);
}
}
}; \ No newline at end of file
diff --git a/commands/uhhhh.js b/commands/uhhhh.js
index ccf94ff..e4d0330 100644
--- a/commands/uhhhh.js
+++ b/commands/uhhhh.js
@@ -1,3 +1,5 @@
+const voice_check_dialog = require('../utils/voice_check_dialog.js');
+
module.exports = {
name: 'uhhhh',
aliases: ['moan'],
@@ -12,10 +14,8 @@ module.exports = {
dispatcher.on('end', () => {
msg.member.voiceChannel.leave();
});
- } else if (msg.guild.voiceConnection) {
- msg.reply('i\'m already playing that lol');
} else {
- msg.reply('you need to join a voice channel first silly');
+ voice_check_dialog.execute(msg);
}
}
}; \ No newline at end of file
diff --git a/commands/volume.js b/commands/volume.js
new file mode 100644
index 0000000..a809c1c
--- /dev/null
+++ b/commands/volume.js
@@ -0,0 +1,15 @@
+module.exports = {
+ name: 'volume',
+ aliases: ['vol'],
+ description: '',
+ async execute(msg, args, bot) {
+ msg.reply('volume is under works rn, just use the slider lol');
+ // if (!args) {
+ // msg.reply('no volume specified >:(');
+ // } else {
+ // var volume = args[0];
+
+ // dispatcher.setVolume(volume);
+ // }
+ }
+}; \ No newline at end of file
diff --git a/commands/wahoo.js b/commands/wahoo.js
index 713ee9d..a6e7c96 100644
--- a/commands/wahoo.js
+++ b/commands/wahoo.js
@@ -1,3 +1,5 @@
+const voice_check_dialog = require('../utils/voice_check_dialog.js');
+
module.exports = {
name: 'wahoo',
aliases: ['mario'],
@@ -12,10 +14,8 @@ module.exports = {
dispatcher.on('end', () => {
msg.member.voiceChannel.leave();
});
- } else if (msg.guild.voiceConnection) {
- msg.reply('i\'m already playing that lol');
} else {
- msg.reply('you need to join a voice channel first silly');
+ voice_check_dialog.execute(msg);
}
}
}; \ No newline at end of file
diff --git a/utils/bot_voice_check.js b/utils/bot_voice_check.js
new file mode 100644
index 0000000..4bef372
--- /dev/null
+++ b/utils/bot_voice_check.js
@@ -0,0 +1,7 @@
+module.exports = {
+ name: 'voice_check',
+ description: '',
+ async execute(msg, args, bot) {
+ if (msg.guild.voiceConnection) return true;
+ }
+}; \ No newline at end of file
diff --git a/utils/no_args.js b/utils/no_args.js
new file mode 100644
index 0000000..ff528da
--- /dev/null
+++ b/utils/no_args.js
@@ -0,0 +1,7 @@
+module.exports = {
+ name: 'no_args',
+ description: '',
+ async execute(msg, args, bot) {
+ msg.channel.send(`invalid argument(s). type \`${config.prefixes.main}help\` for more information.`);
+ }
+}; \ No newline at end of file
diff --git a/utils/no_command.js b/utils/no_command.js
new file mode 100644
index 0000000..04a5768
--- /dev/null
+++ b/utils/no_command.js
@@ -0,0 +1,7 @@
+module.exports = {
+ name: 'no_command',
+ description: '',
+ async execute(msg, args, bot) {
+ msg.channel.send(`invalid or unspecified command. type \`${config.prefixes.main}help\`.`);
+ }
+}; \ No newline at end of file
diff --git a/utils/perms.js b/utils/perms.js
new file mode 100644
index 0000000..9334d91
--- /dev/null
+++ b/utils/perms.js
@@ -0,0 +1,7 @@
+module.exports = {
+ name: 'perms',
+ description: '',
+ async execute(msg, args, bot) {
+ if (msg.member.hasPermission(p)) return true;
+ }
+}; \ No newline at end of file
diff --git a/utils/voice_check_dialog.js b/utils/voice_check_dialog.js
new file mode 100644
index 0000000..fabf1a8
--- /dev/null
+++ b/utils/voice_check_dialog.js
@@ -0,0 +1,11 @@
+module.exports = {
+ name: 'voice_check_dialog',
+ description: '',
+ async execute(msg, args, bot) {
+ if (msg.guild.voiceConnection) {
+ msg.reply('i\'m already playing that lol');
+ } else {
+ msg.reply('you need to join a voice channel first silly');
+ }
+ }
+}; \ No newline at end of file