summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author8cy <[email protected]>2020-04-07 23:09:52 -0700
committer8cy <[email protected]>2020-04-07 23:09:52 -0700
commitd5a459d1b546a44a514205c86e81335caf4c615f (patch)
tree79dafa568428efe060301e2c1da7576c1f3a59d9
parentadd uptime alias, v1.3.4 (diff)
downloads5nical-d5a459d1b546a44a514205c86e81335caf4c615f.tar.xz
s5nical-d5a459d1b546a44a514205c86e81335caf4c615f.zip
rework try/ catch loop to fix errors, v1.4.0
took 2 hours according to github to fix...
-rw-r--r--app.js44
-rw-r--r--commands/botstatus.js6
-rw-r--r--commands/reboot.js16
3 files changed, 53 insertions, 13 deletions
diff --git a/app.js b/app.js
index 61f7756..e69dab1 100644
--- a/app.js
+++ b/app.js
@@ -14,7 +14,7 @@ for (const file of commandFiles) {
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
- bot.user.setActivity('psycho~ uwu', { // Set status
+ bot.user.setActivity('psycho~ uwu', {
type: 'LISTENING'
});
});
@@ -23,16 +23,22 @@ bot.on('error', console.error);
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');
+ } else {
+ // Constants for uptime command
const upTime = require('moment');
require('moment-duration-format');
const duration = upTime.duration(bot.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
+ // Command usage info for logs
var msgContent = msg.content.toLowerCase();
if (prefixCheck()) {
console.log(msg.member.user.tag, 'says', msgContent, 'in #' + msg.channel.name);
}
- // Check prefixies in config.json
+ // Check if message has a prefix in it from config.json
function prefixCheck() {
if (msgContent.startsWith(config.prefixes.main)) {
return "main";
@@ -95,7 +101,7 @@ bot.on('message', async msg => {
if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4b)) return;
}
- // Random edge case arguments
+ // edge case arguments
function noArgs() {
msg.channel.send(`invalid argument(s). type \`${config.prefixes.main}help\` for more information.`);
}
@@ -108,17 +114,36 @@ bot.on('message', async msg => {
if (msg.member.hasPermission(p)) return true;
}
- // Main
+ // Cooldown check
+ // TODO: implament cooldowns when needed https://discordjs.guide/command-handling/adding-features.html#cooldowns
+
+ // Main commands try/ catch
try {
- bot.commands.get(command).execute(msg, args, bot);
+ const cmd = bot.commands.get(command) || bot.commands.find(c => c.aliases && c.aliases.includes(command));
+
+ if (!cmd) {
+ msg.reply('thats not a command silly');
+ } else if (cmd) {
+ cmd.execute(msg, args, bot);
+ }
return;
} catch (error) {
console.error(error);
- //msg.reply('command error\'d out, check logs');
- //return;
+ msg.reply('command error\'d out, check logs. also, how did u manage to break it lol');
+ return;
}
- // Small command which need variables
+ // if (msg.content == 'playing') {
+
+ // } else if (msg.content == 'steaming') {
+
+ // } else if (msg.content == 'listening') {
+
+ // } else if (msg.content == 'watching') {
+
+ // }
+
+ // Small command which need app.js variables
if (command == 'uptime' | command == 'ut') {
msg.reply(duration);
}
@@ -127,7 +152,8 @@ bot.on('message', async msg => {
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;
+ //} else if (msg.channel.name !== 'bots' && msg.content.startsWith(`${config.prefixes.main}`) && !msg.member.hasPermission('KICK_MEMBERS')) return;
+ }
});
// Get bot token
diff --git a/commands/botstatus.js b/commands/botstatus.js
index 6401571..8f9a198 100644
--- a/commands/botstatus.js
+++ b/commands/botstatus.js
@@ -5,9 +5,13 @@ module.exports = {
aliases: ['status', 'bs'],
description: '',
async execute(msg, args, bot) {
+ t = 'LISTENING';
if (msg.member.hasPermission('KICK_MEMBERS')) {
+
m = args.join(' ');
- bot.user.setActivity(m);
+ bot.user.setActivity(m, {
+ type: t
+ });
} else {
msg.reply('insufficent perms bruh');
}
diff --git a/commands/reboot.js b/commands/reboot.js
index 9416730..950da3b 100644
--- a/commands/reboot.js
+++ b/commands/reboot.js
@@ -3,8 +3,18 @@ module.exports = {
aliases: ['r', 're'],
description: '',
execute(msg, args, bot) {
- msg.member.voiceChannel.join();
- msg.member.voiceChannel.leave();
- msg.reply('reboot finished lol');
+ if (args[0] == 'voice' || args[0] == 'v') {
+ if (!msg.member.voiceChannel) {
+ msg.reply('you need to be in a voice channel to reboot the voice module');
+ } else {
+ msg.member.voiceChannel.join();
+ msg.member.voiceChannel.leave();
+ msg.reply('voice module reboot finished lol');
+ }
+ } else if (args[0] == 'commands' || args[0] == 'commands' || args[0] == 'cmds' || args[0] == 'cmd' || args[0] == 'c') {
+ msg.reply('commands module reboot finished lol');
+ } else if (!args.length) {
+ msg.reply('no module(s) specified');
+ }
}
}; \ No newline at end of file