From 116b7f556edfa1e8e73e3ef963cc43bd4cb4c273 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa Date: Thu, 2 Mar 2017 01:23:22 +0530 Subject: [PATCH] Updated to 1.1.0 See https://bastion.js.org/changes/ for complete changelog --- data/quotes.json | 126 ++++++++++++++------ events/channelCreate.js | 6 +- events/channelDelete.js | 6 +- events/channelUpdate.js | 8 +- events/debug.js | 28 ----- events/guildBanAdd.js | 6 +- events/guildBanRemove.js | 6 +- events/guildCreate.js | 8 +- events/guildDelete.js | 8 +- events/guildMemberAdd.js | 14 ++- events/guildMemberRemove.js | 14 ++- events/guildUpdate.js | 6 +- events/message.js | 38 ++++-- events/ready.js | 12 +- handlers/eventHandler.js | 1 - modules/administration/renameTextChannel.js | 4 +- modules/administration/roleColor.js | 4 +- modules/administration/setTopic.js | 4 +- modules/games/flip.js | 4 +- modules/games/magic8ball.js | 4 +- modules/games/roll.js | 4 +- modules/games/rps.js | 4 +- modules/guildAdmin/chat.js | 4 +- modules/guildAdmin/farewell.js | 4 +- modules/guildAdmin/farewellMessage.js | 4 +- modules/guildAdmin/farewellTimeout.js | 4 +- modules/guildAdmin/filterInvite.js | 4 +- modules/guildAdmin/greet.js | 4 +- modules/guildAdmin/greetMessage.js | 4 +- modules/guildAdmin/greetTimeout.js | 4 +- modules/guildAdmin/levelUpMessage.js | 62 ++++++++++ modules/guildAdmin/log.js | 4 +- modules/help/commands.js | 8 +- modules/help/donate.js | 5 +- modules/help/help.js | 34 +++++- modules/help/info.js | 4 +- modules/help/ping.js | 4 +- modules/help/support.js | 10 +- modules/moderation/addRole.js | 4 +- modules/moderation/ban.js | 12 +- modules/moderation/clear.js | 2 + modules/moderation/deafen.js | 4 +- modules/moderation/inRole.js | 4 +- modules/moderation/kick.js | 12 +- modules/moderation/mute.js | 4 +- modules/moderation/removeRole.js | 4 +- modules/moderation/softBan.js | 16 ++- modules/moderation/unDeafen.js | 4 +- modules/moderation/unMute.js | 4 +- modules/money/betFlip.js | 12 +- modules/money/betRoll.js | 16 ++- modules/money/give.js | 24 +++- modules/money/hallOfFame.js | 4 +- modules/money/leaderboard.js | 4 +- modules/money/profile.js | 6 +- modules/money/take.js | 8 +- modules/music/np.js | 4 +- modules/music/pause.js | 4 +- modules/music/play.js | 64 ++++++++-- modules/music/queue.js | 4 +- modules/music/resume.js | 4 +- modules/music/skip.js | 4 +- modules/music/stop.js | 4 +- modules/music/summon.js | 28 +++-- modules/music/volume.js | 4 +- modules/owner/addMusicChannel.js | 4 +- modules/owner/addTrigger.js | 8 +- modules/owner/announce.js | 4 +- modules/owner/deleteTriggers.js | 4 +- modules/owner/leave.js | 4 +- modules/owner/listTriggers.js | 4 +- modules/owner/messageUser.js | 3 +- modules/owner/setAvatar.js | 6 +- modules/owner/setGame.js | 12 +- modules/owner/setStatus.js | 12 +- modules/owner/setStream.js | 9 +- modules/owner/setUsername.js | 8 +- modules/owner/shutdown.js | 8 +- modules/owner/userBlacklist.js | 8 +- modules/queries/ask.js | 48 ++++---- modules/queries/avatar.js | 4 +- modules/queries/calculate.js | 4 +- modules/queries/catFact.js | 4 +- modules/queries/channelID.js | 4 +- modules/queries/channelInfo.js | 4 +- modules/queries/channelTopic.js | 4 +- modules/queries/choose.js | 4 +- modules/queries/color.js | 4 +- modules/queries/crimeCoefficient.js | 4 +- modules/queries/define.js | 4 +- modules/queries/echo.js | 4 +- modules/queries/flipText.js | 6 +- modules/queries/forecast.js | 4 +- modules/queries/fortune.js | 4 +- modules/queries/imdb.js | 4 +- modules/queries/leet.js | 4 +- modules/queries/lmgtfy.js | 4 +- modules/queries/morseCode.js | 4 +- modules/queries/overwatch.js | 4 +- modules/queries/poll.js | 14 ++- modules/queries/quotes.js | 4 +- modules/queries/reverse.js | 4 +- modules/queries/roles.js | 4 +- modules/queries/serverID.js | 4 +- modules/queries/serverInfo.js | 4 +- modules/queries/sweep.js | 4 +- modules/queries/tapCode.js | 4 +- modules/queries/translate.js | 4 +- modules/queries/urbanDictionary.js | 4 +- modules/queries/userID.js | 4 +- modules/queries/userInfo.js | 4 +- modules/queries/weather.js | 4 +- modules/queries/wikipedia.js | 4 +- modules/queries/xkcd.js | 12 +- package.json | 4 +- run.sh | 7 ++ update.cmd | 29 +++++ update.sh | 27 +++++ 118 files changed, 831 insertions(+), 276 deletions(-) delete mode 100644 events/debug.js create mode 100644 modules/guildAdmin/levelUpMessage.js create mode 100644 update.cmd create mode 100644 update.sh diff --git a/data/quotes.json b/data/quotes.json index 126f778b9..b061af294 100644 --- a/data/quotes.json +++ b/data/quotes.json @@ -452,7 +452,7 @@ "author": "Albert Einstein" }, "114": { - "quote": "If A is a success in life, then A equals X plus Y plus Z. Work is X; Y is play; and Z is keeping your mouth shut.", + "quote": "If A is a success in life, then A equals X plus Y plus Z. X is work; Y is play; and Z is keeping your mouth shut.", "author": "Albert Einstein" }, "115": { @@ -812,71 +812,127 @@ "author": "Ray Kroc" }, "204": { - "quote": "", - "author": "-" + "quote": "Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine.", + "author": "Nikola Tesla" }, "205": { - "quote": "", - "author": "-" + "quote": "I don't care that they stole my idea . . I care that they don't have any of their own.", + "author": "Nikola Tesla" }, "206": { - "quote": "", - "author": "-" + "quote": "Be alone, that is the secret of invention; be alone, that is when ideas are born.", + "author": "Nikola Tesla" }, "207": { - "quote": "", - "author": "-" + "quote": "I do not think there is any thrill that can go through the human heart like that felt by the inventor as he sees some creation of the brain unfolding to success . . . Such emotions make a man forget food, sleep, friends, love, everything.", + "author": "Nikola Tesla" }, "208": { - "quote": "", - "author": "-" + "quote": "I have not failed. I've just found 10,000 ways that won't work.", + "author": "Thomas Alva Edison" }, "209": { - "quote": "", - "author": "-" + "quote": "If we all did the things we are capable of doing, we would literally astound ourselves.", + "author": "Thomas Alva Edison" }, "210": { - "quote": "", - "author": "-" + "quote": "Show me a thoroughly satisfied man and I will show you a failure.", + "author": "Thomas Alva Edison" }, "211": { - "quote": "", - "author": "-" + "quote": "Our greatest weakness lies in giving up. The most certain way to succeed is always to try just one more time.", + "author": "Thomas Alva Edison" }, "212": { - "quote": "", - "author": "-" + "quote": "Just because something doesn't do what you planned it to do doesn't mean it's useless.", + "author": "Thomas Alva Edison" }, "213": { - "quote": "", - "author": "-" + "quote": "Everything comes to him who hustles while he waits.", + "author": "Thomas Alva Edison" }, "214": { - "quote": "", - "author": "-" + "quote": "Negative results are just what I want. They’re just as valuable to me as positive results. I can never find the thing that does the job best until I find the ones that don’t.", + "author": "Thomas Alva Edison" }, "215": { - "quote": "", - "author": "-" + "quote": "Success is a lousy teacher. It seduces smart people into thinking they can't lose.", + "author": "Bill Gates" }, "216": { - "quote": "", - "author": "-" + "quote": "Your most unhappy customers are your greatest source of learning.", + "author": "Bill Gates" }, "217": { - "quote": "", - "author": "-" + "quote": "It's fine to celebrate success but it is more important to heed the lessons of failure.", + "author": "Bill Gates" }, "218": { - "quote": "", - "author": "-" + "quote": "Don't compare yourself with anyone in this world...if you do so, you are insulting yourself.", + "author": "Bill Gates" }, "219": { - "quote": "", - "author": "-" + "quote": "I choose a lazy person to do a hard job. Because a lazy person will find an easy way to do it.", + "author": "Bill Gates" }, "220": { - "quote": "", - "author": "-" + "quote": "I failed in some subjects in exam, but my friend passed in all. Now he is an engineer in Microsoft and I am the owner of Microsoft.", + "author": "Bill Gates" + }, + "221": { + "quote": "Most people overestimate what they can do in one year and underestimate what they can do in ten years.", + "author": "Bill Gates" + }, + "222": { + "quote": "If you are born poor its not your mistake, But if you die poor its your mistake.", + "author": "Bill Gates" + }, + "223": { + "quote": "If you give people tools, and they use their natural abilities and their curiosity, they will develop things in ways that will surprise you very much beyond what you might have expected.", + "author": "Bill Gates" + }, + "224": { + "quote": "Measuring programming progress by lines of code is like measuring aircraft building progress by weight.", + "author": "Bill Gates" + }, + "225": { + "quote": "Some people may call me a nerd. I claim the label with pride.", + "author": "Bill Gates" + }, + "226": { + "quote": "To win big, you sometimes have to take big risks.", + "author": "Bill Gates" + }, + "227": { + "quote": "Long ago, Ben Graham taught me that 'Price is what you pay; value is what you get.' Whether we're talking about socks or stocks, I like buying quality merchandise when it is marked down.", + "author": "Warren Buffet" + }, + "228": { + "quote": "It takes 20 years to build a reputation and five minutes to ruin it. If you think about that, you'll do things differently.", + "author": "Warren Buffet" + }, + "229": { + "quote": "Someone's sitting in the shade today because someone planted a tree a long time ago.", + "author": "Warren Buffet" + }, + "230": { + "quote": "Rule No.1: Never lose money. Rule No.2: Never forget rule No.1.", + "author": "Warren Buffet" + }, + "231": { + "quote": "It's better to hang out with people better than you. Pick out associates whose behavior is better than yours and you'll drift in that direction.", + "author": "Warren Buffet" + }, + "232": { + "quote": "No matter how great the talent or effort, some things just take time.", + "author": "Warren Buffet" + }, + "233": { + "quote": "The difference between successful people and really successful people is that really successful people say no to almost everything.", + "author": "Warren Buffet" + }, + "234": { + "quote": "I always knew I was going to be rich. I don’t think I ever doubted it for a minute.", + "author": "Warren Buffet" } } diff --git a/events/channelCreate.js b/events/channelCreate.js index 5dabd5abb..cae5ea70d 100644 --- a/events/channelCreate.js +++ b/events/channelCreate.js @@ -50,8 +50,10 @@ module.exports = channel => { inline: false } ] - }}); + }}).catch(e => { + channel.client.log.error(e.stack); + }); }).catch(e => { channel.client.log.error(e.stack); - });; + }); }; diff --git a/events/channelDelete.js b/events/channelDelete.js index 6dd1d62bc..4404fe348 100644 --- a/events/channelDelete.js +++ b/events/channelDelete.js @@ -50,8 +50,10 @@ module.exports = channel => { inline: true } ] - }}); + }}).catch(e => { + channel.client.log.error(e.stack); + }); }).catch(e => { channel.client.log.error(e.stack); - });; + }); }; diff --git a/events/channelUpdate.js b/events/channelUpdate.js index 8f8066b85..fb9e5bfed 100644 --- a/events/channelUpdate.js +++ b/events/channelUpdate.js @@ -57,8 +57,10 @@ module.exports = (oldChannel, newChannel) => { inline: true } ] - }}); + }}).catch(e => { + newChannel.client.log.error(e.stack); + }); }).catch(e => { - channel.client.log.error(e.stack); - });; + newChannel.client.log.error(e.stack); + }); }; diff --git a/events/debug.js b/events/debug.js deleted file mode 100644 index 5f6c27319..000000000 --- a/events/debug.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 Sankarsan Kampa - * https://sankarsankampa.com/contact - * - * This file is a part of Bastion Discord BOT. - * https://github.com/snkrsnkampa/Bastion - * - * This code is licensed under the SNKRSN Shared License. It is free to - * download, copy, compile, use, study and refer under the terms of the - * SNKRSN Shared License. You can modify the code only for personal or - * internal use only. However, you can not redistribute the code without - * explicitly getting permission fot it. - * - * Bastion BOT is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY. See the SNKRSN Shared License for - * more details. - * - * You should have received a copy of the SNKRSN Shared License along - * with this program. If not, see . - */ - -const chalk = require('chalk'); - -module.exports = info => { - console.log(chalk.blue('[DEBUG]')); - console.log(info); - console.log(chalk.blue('[/DEBUG]')); -}; diff --git a/events/guildBanAdd.js b/events/guildBanAdd.js index da8a52bf2..fcd33f3c4 100644 --- a/events/guildBanAdd.js +++ b/events/guildBanAdd.js @@ -45,6 +45,10 @@ module.exports = (guild, user) => { inline: false } ] - }}); + }}).catch(e => { + guild.client.log.error(e.stack); + }); + }).catch(e => { + guild.client.log.error(e.stack); }); }; diff --git a/events/guildBanRemove.js b/events/guildBanRemove.js index 3e329af1f..4572186c5 100644 --- a/events/guildBanRemove.js +++ b/events/guildBanRemove.js @@ -45,6 +45,10 @@ module.exports = (guild, user) => { inline: false } ] - }}); + }}).catch(e => { + guild.client.log.error(e.stack); + }); + }).catch(e => { + guild.client.log.error(e.stack); }); }; diff --git a/events/guildCreate.js b/events/guildCreate.js index ae2610434..c40ad6134 100644 --- a/events/guildCreate.js +++ b/events/guildCreate.js @@ -23,7 +23,11 @@ const sql = require('sqlite'); sql.open('./data/Bastion.sqlite'); module.exports = guild => { - sql.run("CREATE TABLE IF NOT EXISTS guildSettings (guildID TEXT NOT NULL UNIQUE, greet TEXT NOT NULL DEFAULT 'false', greetChannelID TEXT, greetMessage TEXT NOT NULL DEFAULT 'Welcome to $server.', greetTimeout INTEGER NOT NULL DEFAULT 30, farewell TEXT NOT NULL DEFAULT 'false', farewellChannelID TEXT UNIQUE, farewellMessage TEXT NOT NULL DEFAULT 'We hope you enjoyed your stay here!', farewellTimeout INTEGER NOT NULL DEFAULT 15, log TEXT NOT NULL DEFAULT 'false', logChannelID TEXT UNIQUE, musicTextChannelID TEXT UNIQUE, musicVoiceChannelID TEXT UNIQUE, filterInvite TEXT NOT NULL DEFAULT 'false', chat TEXT NOT NULL DEFAULT 'false', PRIMARY KEY(guildID))").then(() => { - sql.run('INSERT OR IGNORE INTO guildSettings (guildID) VALUES (?)', [guild.id]); + sql.run("CREATE TABLE IF NOT EXISTS guildSettings (guildID TEXT NOT NULL UNIQUE, greet TEXT NOT NULL DEFAULT 'false', greetChannelID TEXT, greetMessage TEXT NOT NULL DEFAULT 'Welcome to $server.', greetTimeout INTEGER NOT NULL DEFAULT 30, farewell TEXT NOT NULL DEFAULT 'false', farewellChannelID TEXT UNIQUE, farewellMessage TEXT NOT NULL DEFAULT 'We hope you enjoyed your stay here!', farewellTimeout INTEGER NOT NULL DEFAULT 15, log TEXT NOT NULL DEFAULT 'false', logChannelID TEXT UNIQUE, musicTextChannelID TEXT UNIQUE, musicVoiceChannelID TEXT UNIQUE, filterInvite TEXT NOT NULL DEFAULT 'false', chat TEXT NOT NULL DEFAULT 'false', levelUpMessage TEXT NOT NULL DEFAULT 'true', PRIMARY KEY(guildID))").then(() => { + sql.run('INSERT OR IGNORE INTO guildSettings (guildID) VALUES (?)', [guild.id]).catch(e => { + guild.client.log.error(e.stack); + }); + }).catch(e => { + guild.client.log.error(e.stack); }); }; diff --git a/events/guildDelete.js b/events/guildDelete.js index 308098b0d..f365e6bdd 100644 --- a/events/guildDelete.js +++ b/events/guildDelete.js @@ -23,9 +23,7 @@ const sql = require('sqlite'); sql.open('./data/Bastion.sqlite'); module.exports = guild => { - if(guild.available) { - sql.run(`DELETE FROM guildSettings WHERE guildID=${guild.id}`); - } else { - console.log(`${guild.name} guild with ID: ${guild.id} is not available at the moment. Mostly, this is the cause of a server outage.`); - } + sql.run(`DELETE FROM guildSettings WHERE guildID=${guild.id}`).catch(e => { + guild.client.log.error(e.stack); + }); }; diff --git a/events/guildMemberAdd.js b/events/guildMemberAdd.js index 9fe2bf556..722bc4a9e 100644 --- a/events/guildMemberAdd.js +++ b/events/guildMemberAdd.js @@ -35,9 +35,15 @@ module.exports = member => { title: `Hello ${member.displayName}`, description: greetMsg }}).then(m => { - if (greetTimeout > 0) m.delete(1000*parseInt(greetTimeout)); + if (greetTimeout > 0) m.delete(1000*parseInt(greetTimeout)).catch(e => { + member.client.log.error(e.stack); + }); + }).catch(e => { + member.client.log.error(e.stack); }); } + }).catch(e => { + member.client.log.error(e.stack); }); sql.get(`SELECT log, logChannelID FROM guildSettings WHERE guildID ='${member.guild.id}'`).then(row => { @@ -62,6 +68,10 @@ module.exports = member => { inline: false } ] - }}); + }}).catch(e => { + member.client.log.error(e.stack); + }); + }).catch(e => { + member.client.log.error(e.stack); }); }; diff --git a/events/guildMemberRemove.js b/events/guildMemberRemove.js index 639feecc8..0d64132c1 100644 --- a/events/guildMemberRemove.js +++ b/events/guildMemberRemove.js @@ -35,9 +35,15 @@ module.exports = member => { title: `Goodbye ${member.displayName}!`, description: farewellMsg + '\n:wave:' }}).then(m => { - if (farewellTimeout > 0) m.delete(1000*parseInt(farewellTimeout)); + if (farewellTimeout > 0) m.delete(1000*parseInt(farewellTimeout)).catch(e => { + member.client.log.error(e.stack); + }); + }).catch(e => { + member.client.log.error(e.stack); }); } + }).catch(e => { + member.client.log.error(e.stack); }); sql.get(`SELECT log, logChannelID FROM guildSettings WHERE guildID ='${member.guild.id}'`).then(row => { @@ -62,6 +68,10 @@ module.exports = member => { inline: false } ] - }}); + }}).catch(e => { + member.client.log.error(e.stack); + }); + }).catch(e => { + member.client.log.error(e.stack); }); }; diff --git a/events/guildUpdate.js b/events/guildUpdate.js index 6cb2c719a..58c97c075 100644 --- a/events/guildUpdate.js +++ b/events/guildUpdate.js @@ -46,6 +46,10 @@ module.exports = (oldGuild, newGuild) => { inline: true } ] - }}); + }}).catch(e => { + newGuild.client.log.error(e.stack); + }); + }).catch(e => { + newGuild.client.log.error(e.stack); }); }; diff --git a/events/message.js b/events/message.js index 801e23dbc..a0893b571 100644 --- a/events/message.js +++ b/events/message.js @@ -31,7 +31,7 @@ module.exports = message => { if (message.content.startsWith(`${message.client.config.prefix}h`) || message.content.startsWith(`${message.client.config.prefix}help`)) return message.channel.sendMessage('', {embed: { color: 6651610, title: 'Bastion Discord BOT', - // TODO: url + url: 'https://bastion.js.org', description: 'Join [**Bastion Support Server**](https://discord.gg/fzx8fkt) for any help you need.', fields: [ { @@ -50,7 +50,9 @@ module.exports = message => { icon_url: 'https://sankarsankampa.com/assets/img/logo/snkrsn_32.png', text: 'Copyright © 2017 Sankarsan Kampa | @snkrsnkampa' } - }}); + }}).catch(e => { + message.client.log.error(e.stack); + }); return; } @@ -73,7 +75,9 @@ module.exports = message => { msg = msg.replace(/\$user/ig, `<@${message.author.id}>`); msg = msg.replace(/\$username/ig, message.author.username); msg = msg.replace(/\$server/ig, `**${message.guild.name}**`); - return message.channel.sendMessage(msg); + return message.channel.sendMessage(msg).catch(e => { + message.client.log.error(e.stack); + }); } } }).catch(() => { @@ -93,15 +97,21 @@ module.exports = message => { else { let currentLevel = Math.floor(0.1 * Math.sqrt(profile.xp + 1)); if (currentLevel > profile.level) { - profile.level = currentLevel; - sql.run(`UPDATE profiles SET bastionCurrencies=${profile.bastionCurrencies+profile.level*5}, xp=${profile.xp+1}, level=${profile.level} WHERE userID=${message.author.id}`).catch(e => { + sql.run(`UPDATE profiles SET bastionCurrencies=${profile.bastionCurrencies+currentLevel*5}, xp=${profile.xp+1}, level=${currentLevel} WHERE userID=${message.author.id}`).catch(e => { + message.client.log.error(e.stack); + }); + sql.get(`SELECT levelUpMessage FROM guildSettings WHERE guildID=${message.guild.id}`).then(guild => { + if (guild.levelUpMessage = 'false') return; + message.channel.sendMessage('', {embed: { + color: 11316394, + title: 'Leveled up', + description: `:up: **${message.author.username}**#${message.author.discriminator} leveled up to **Level ${currentLevel}**` + }}).catch(e => { + message.client.log.error(e.stack); + }); + }).catch(e => { message.client.log.error(e.stack); }); - message.channel.sendMessage('', {embed: { - color: 11316394, - title: 'Leveled up', - description: `:up: **${message.author.username}**#${message.author.discriminator} leveled up to **Level ${currentLevel}**` - }}); } else sql.run(`UPDATE profiles SET xp=${profile.xp+1} WHERE userID=${message.author.id}`).catch(e => { message.client.log.error(e.stack); @@ -151,8 +161,12 @@ module.exports = message => { bot.ask(args.join(' '), function (err, response) { message.channel.startTyping(); setTimeout(function () { - message.channel.sendMessage(response); - message.channel.stopTyping(); + message.channel.sendMessage(response).catch(e => { + message.client.log.error(e.stack); + }); + message.channel.stopTyping().catch(e => { + message.client.log.error(e.stack); + }); }, response.length * 100); }); }); diff --git a/events/ready.js b/events/ready.js index 52cab05cb..7afdb3ef8 100644 --- a/events/ready.js +++ b/events/ready.js @@ -27,7 +27,7 @@ module.exports = Bastion => { Bastion.user.setStatus(Bastion.config.status); Bastion.user.setGame(Bastion.config.game); - sql.run("CREATE TABLE IF NOT EXISTS guildSettings (guildID TEXT NOT NULL UNIQUE, greet TEXT NOT NULL DEFAULT 'false', greetChannelID TEXT, greetMessage TEXT NOT NULL DEFAULT 'Welcome to $server.', greetTimeout INTEGER NOT NULL DEFAULT 30, farewell TEXT NOT NULL DEFAULT 'false', farewellChannelID TEXT UNIQUE, farewellMessage TEXT NOT NULL DEFAULT 'We hope you enjoyed your stay here!', farewellTimeout INTEGER NOT NULL DEFAULT 15, log TEXT NOT NULL DEFAULT 'false', logChannelID TEXT UNIQUE, musicTextChannelID TEXT UNIQUE, musicVoiceChannelID TEXT UNIQUE, filterInvite TEXT NOT NULL DEFAULT 'false', chat TEXT NOT NULL DEFAULT 'false', PRIMARY KEY(guildID))").then(() => { + sql.run("CREATE TABLE IF NOT EXISTS guildSettings (guildID TEXT NOT NULL UNIQUE, greet TEXT NOT NULL DEFAULT 'false', greetChannelID TEXT, greetMessage TEXT NOT NULL DEFAULT 'Welcome to $server.', greetTimeout INTEGER NOT NULL DEFAULT 30, farewell TEXT NOT NULL DEFAULT 'false', farewellChannelID TEXT UNIQUE, farewellMessage TEXT NOT NULL DEFAULT 'We hope you enjoyed your stay here!', farewellTimeout INTEGER NOT NULL DEFAULT 15, log TEXT NOT NULL DEFAULT 'false', logChannelID TEXT UNIQUE, musicTextChannelID TEXT UNIQUE, musicVoiceChannelID TEXT UNIQUE, filterInvite TEXT NOT NULL DEFAULT 'false', chat TEXT NOT NULL DEFAULT 'false', levelUpMessage TEXT NOT NULL DEFAULT 'true', PRIMARY KEY(guildID))").then(() => { let BastionGuilds = Bastion.guilds.map(g => g.id); sql.all('SELECT guildID from guildSettings').then(row => { row = row.map(r => r.guildID); @@ -40,7 +40,9 @@ module.exports = Bastion => { } } if(found == false) - sql.run('INSERT INTO guildSettings (guildID) VALUES (?)', [`${BastionGuilds[i]}`]); + sql.run('INSERT INTO guildSettings (guildID) VALUES (?)', [`${BastionGuilds[i]}`]).catch(e => { + Bastion.log.error(e.stack); + }); } for (var i = 0; i < row.length; i++) { var found = false; @@ -51,11 +53,15 @@ module.exports = Bastion => { } } if(found == false) - sql.run(`DELETE FROM guildSettings WHERE guildID=${row[i]}`); + sql.run(`DELETE FROM guildSettings WHERE guildID=${row[i]}`).catch(e => { + Bastion.log.error(e.stack); + }); } }).catch(e => { Bastion.log.error(e.stack); }); + }).catch(e => { + Bastion.log.error(e.stack); }); sql.run("CREATE TABLE IF NOT EXISTS blacklistedUsers (userID TEXT NOT NULL UNIQUE, PRIMARY KEY(userID))").catch(e => { Bastion.log.error(e.stack); diff --git a/handlers/eventHandler.js b/handlers/eventHandler.js index ac7a1310a..9cb49ddce 100644 --- a/handlers/eventHandler.js +++ b/handlers/eventHandler.js @@ -25,7 +25,6 @@ module.exports = Bastion => { Bastion.on('channelCreate', loadEvent('channelCreate')); Bastion.on('channelDelete', loadEvent('channelDelete')); Bastion.on('channelUpdate', loadEvent('channelUpdate')); - // Bastion.on('debug', loadEvent('debug')); Bastion.on('disconnect', () => loadEvent('disconnect')(Bastion)); Bastion.on('error', loadEvent('error')); Bastion.on('guildBanAdd', loadEvent('guildBanAdd')); diff --git a/modules/administration/renameTextChannel.js b/modules/administration/renameTextChannel.js index d8f16ad8e..b6e814e38 100644 --- a/modules/administration/renameTextChannel.js +++ b/modules/administration/renameTextChannel.js @@ -28,7 +28,9 @@ exports.run = function(Bastion, message, args) { color: 5088314, title: 'Channel Name Changed', description: args.join('-') - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/administration/roleColor.js b/modules/administration/roleColor.js index a63fb250a..e15ca2a6e 100644 --- a/modules/administration/roleColor.js +++ b/modules/administration/roleColor.js @@ -47,7 +47,9 @@ exports.run = function(Bastion, message, args) { thumbnail: { url: `https://dummyimage.com/250/${args[0].slice(1)}/&text=%20`, } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/administration/setTopic.js b/modules/administration/setTopic.js index 81486ce00..a50c4f245 100644 --- a/modules/administration/setTopic.js +++ b/modules/administration/setTopic.js @@ -35,7 +35,9 @@ exports.run = function(Bastion, message, args) { color: 5088314, title: title, description: topic - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/games/flip.js b/modules/games/flip.js index a81c277ad..2e8665854 100644 --- a/modules/games/flip.js +++ b/modules/games/flip.js @@ -28,7 +28,9 @@ exports.run = function(Bastion, message, args) { message.channel.sendMessage('', {embed: { color: 6651610, description: outcomes[Math.floor(Math.random()*outcomes.length)], - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/games/magic8ball.js b/modules/games/magic8ball.js index 1390bab85..c6a674272 100644 --- a/modules/games/magic8ball.js +++ b/modules/games/magic8ball.js @@ -51,7 +51,9 @@ exports.run = function(Bastion, message, args) { footer: { text: '🎱 Magic 8-ball' } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/games/roll.js b/modules/games/roll.js index 118b249fc..d14dc3e8b 100644 --- a/modules/games/roll.js +++ b/modules/games/roll.js @@ -37,7 +37,9 @@ exports.run = function(Bastion, message, args) { color: 6651610, title: 'You rolled:', description: outcome - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/games/rps.js b/modules/games/rps.js index 283abeed4..113c4887d 100644 --- a/modules/games/rps.js +++ b/modules/games/rps.js @@ -44,7 +44,9 @@ exports.run = function(Bastion, message, args) { message.channel.sendMessage('', {embed: { color: 6651610, description: `You chose **${userOutcome}**, I chose **${botOutcome}**. *${result}*` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/guildAdmin/chat.js b/modules/guildAdmin/chat.js index b5657abe7..5630781d9 100644 --- a/modules/guildAdmin/chat.js +++ b/modules/guildAdmin/chat.js @@ -42,7 +42,9 @@ exports.run = function(Bastion, message, args) { message.channel.sendMessage('', {embed: { color: 5088314, description: chatStats - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/guildAdmin/farewell.js b/modules/guildAdmin/farewell.js index 9e463cbd3..ea891f3c0 100644 --- a/modules/guildAdmin/farewell.js +++ b/modules/guildAdmin/farewell.js @@ -43,7 +43,9 @@ exports.run = function(Bastion, message, args) { message.channel.sendMessage('', {embed: { color: 5088314, description: farewellStats - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/guildAdmin/farewellMessage.js b/modules/guildAdmin/farewellMessage.js index b394f0de6..967bb68a9 100644 --- a/modules/guildAdmin/farewellMessage.js +++ b/modules/guildAdmin/farewellMessage.js @@ -34,7 +34,9 @@ exports.run = function(Bastion, message, args) { color: 5088314, title: 'Farewell message set to:', description: args.join(' ') - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/guildAdmin/farewellTimeout.js b/modules/guildAdmin/farewellTimeout.js index 5c9709466..44d373fc0 100644 --- a/modules/guildAdmin/farewellTimeout.js +++ b/modules/guildAdmin/farewellTimeout.js @@ -34,7 +34,9 @@ exports.run = function(Bastion, message, args) { color: 5088314, title: 'Farewell Timeout set to:', description: args[0] > 60 ? `${args[0] / 60} min.` : args[0] == 0 ? '∞' : `${args[0]} sec.` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/guildAdmin/filterInvite.js b/modules/guildAdmin/filterInvite.js index 450d92180..09305dfac 100644 --- a/modules/guildAdmin/filterInvite.js +++ b/modules/guildAdmin/filterInvite.js @@ -42,7 +42,9 @@ exports.run = function(Bastion, message, args) { message.channel.sendMessage('', {embed: { color: 5088314, description: filterInviteStats - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/guildAdmin/greet.js b/modules/guildAdmin/greet.js index 5895be444..2de421a34 100644 --- a/modules/guildAdmin/greet.js +++ b/modules/guildAdmin/greet.js @@ -42,7 +42,9 @@ exports.run = function(Bastion, message, args) { message.channel.sendMessage('', {embed: { color: 5088314, description: greetStats - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/guildAdmin/greetMessage.js b/modules/guildAdmin/greetMessage.js index 6a10aa671..a70a41184 100644 --- a/modules/guildAdmin/greetMessage.js +++ b/modules/guildAdmin/greetMessage.js @@ -34,7 +34,9 @@ exports.run = function(Bastion, message, args) { color: 5088314, title: 'Greeting message set to:', description: args.join(' ') - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/guildAdmin/greetTimeout.js b/modules/guildAdmin/greetTimeout.js index 8a8ff9434..c6c7d77b9 100644 --- a/modules/guildAdmin/greetTimeout.js +++ b/modules/guildAdmin/greetTimeout.js @@ -34,7 +34,9 @@ exports.run = function(Bastion, message, args) { color: 5088314, title: 'Greet Timeout set to:', description: args[0] > 60 ? `${args[0] / 60} min.` : args[0] == 0 ? '∞' : `${args[0]} sec.` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/guildAdmin/levelUpMessage.js b/modules/guildAdmin/levelUpMessage.js new file mode 100644 index 000000000..23a8f7798 --- /dev/null +++ b/modules/guildAdmin/levelUpMessage.js @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2017 Sankarsan Kampa + * https://sankarsankampa.com/contact + * + * This file is a part of Bastion Discord BOT. + * https://github.com/snkrsnkampa/Bastion + * + * This code is licensed under the SNKRSN Shared License. It is free to + * download, copy, compile, use, study and refer under the terms of the + * SNKRSN Shared License. You can modify the code only for personal or + * internal use only. However, you can not redistribute the code without + * explicitly getting permission fot it. + * + * Bastion BOT is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY. See the SNKRSN Shared License for + * more details. + * + * You should have received a copy of the SNKRSN Shared License along + * with this program. If not, see . + */ + +const sql = require('sqlite'); +sql.open('./data/Bastion.sqlite'); + +exports.run = function(Bastion, message, args) { + if (Bastion.credentials.ownerId.indexOf(message.author.id) < 0 && !message.guild.members.get(message.author.id).hasPermission("ADMINISTRATOR")) return Bastion.log.info('You don\'t have permissions to use this command.'); + + sql.get(`SELECT levelUpMessage FROM guildSettings WHERE guildID ='${message.guild.id}'`).then(guild => { + if (guild.levelUpMessage == 'true') { + sql.run(`UPDATE guildSettings SET levelUpMessage='false' WHERE guildID='${message.guild.id}'`).catch(e => { + Bastion.log.error(e.stack); + }); + levelUpMessageStats = 'I won\'t any send messages when someone levels up from now on.'; + } + else { + sql.run(`UPDATE guildSettings SET levelUpMessage='true' WHERE guildID='${message.guild.id}'`).catch(e => { + Bastion.log.error(e.stack); + }); + levelUpMessageStats = 'I will now send messages when someone levels up.'; + } + + message.channel.sendMessage('', {embed: { + color: 5088314, + description: levelUpMessageStats + }}).catch(e => { + Bastion.log.error(e.stack); + }); + }).catch(e => { + Bastion.log.error(e.stack); + }); +}; + +exports.conf = { + aliases: ['lvlupmsg'] +}; + +exports.help = { + name: 'levelupmessage', + description: 'Toggles sending messages when someone levels up in this server.', + permission: '', + usage: ['levelUpMessage'] +}; diff --git a/modules/guildAdmin/log.js b/modules/guildAdmin/log.js index f0b23edf3..3cd275130 100644 --- a/modules/guildAdmin/log.js +++ b/modules/guildAdmin/log.js @@ -42,7 +42,9 @@ exports.run = function(Bastion, message, args) { message.channel.sendMessage('', {embed: { color: 5088314, description: logStats - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/help/commands.js b/modules/help/commands.js index 96a7cc333..e02b1d1fa 100644 --- a/modules/help/commands.js +++ b/modules/help/commands.js @@ -29,12 +29,18 @@ exports.run = function(Bastion, message, args) { name: 'Help', value: `To get help/details about a command, type \`${Bastion.config.prefix}help command_name\``, inline: true + }, + { + name: 'Commands List', + value: 'To get a complete list of all the commands with details click [here](https://bastion.js.org/commands).' } ], footer: { text: `Prefix: ${Bastion.config.prefix} | Total Commands: ${Bastion.commands.size}` } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/help/donate.js b/modules/help/donate.js index ef163ba25..b5c810847 100644 --- a/modules/help/donate.js +++ b/modules/help/donate.js @@ -23,8 +23,11 @@ exports.run = function(Bastion, message, args) { message.channel.sendMessage('', {embed: { color: 3050327, title: 'Support Bastion BOT project', + url: 'https://bastion.js.org/', description: `You can support the Bastion BOT project on patreon: https://patreon.com/snkrsnkampa\n\nOR\n\nYou can send donations to https://paypal.me/snkrsnkampa\n\nDon't forget to leave your Discord username and/or user id in the message.\n\nThank you :hearts:️`, - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/help/help.js b/modules/help/help.js index 9510873be..7564aa0f9 100644 --- a/modules/help/help.js +++ b/modules/help/help.js @@ -28,8 +28,34 @@ exports.run = function(Bastion, message, args) { footer: { text: `Prefix: ${Bastion.config.prefix} | Total Commands: ${Bastion.commands.size}` } - }}); - + }}).catch(e => { + Bastion.log.error(e.stack); + }); + message.author.sendMessage('', {embed: { + color: 6651610, + title: 'Bastion Discord BOT', + url: 'https://bastion.js.org', + description: 'Join [**Bastion Support Server**](https://discord.gg/fzx8fkt) for any help you need.', + fields: [ + { + name: 'Support Server Invite Link', + value: 'https://discord.gg/fzx8fkt' + }, + { + name: 'BOT Invite Link', + value: `https://discordapp.com/oauth2/authorize?client_id=${message.client.user.id}&scope=bot&permissions=2146958463` + } + ], + thumbnail: { + url: message.client.user.avatarURL + }, + footer: { + icon_url: 'https://sankarsankampa.com/assets/img/logo/snkrsn_32.png', + text: 'Copyright © 2017 Sankarsan Kampa | @snkrsnkampa' + } + }}).catch(e => { + message.client.log.error(e.stack); + }); } else { let command = args[0]; if (Bastion.commands.has(command)) { @@ -73,7 +99,9 @@ exports.run = function(Bastion, message, args) { inline: true } ] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); } } }; diff --git a/modules/help/info.js b/modules/help/info.js index 7c5e45954..788f27e40 100644 --- a/modules/help/info.js +++ b/modules/help/info.js @@ -88,7 +88,9 @@ exports.run = function(Bastion, message, args) { text: `Ping: ${parseInt(Bastion.ping)}ms` }, timestamp: new Date() - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/help/ping.js b/modules/help/ping.js index 340582f41..aecce7ebf 100644 --- a/modules/help/ping.js +++ b/modules/help/ping.js @@ -23,7 +23,9 @@ exports.run = function(Bastion, message, args) { message.channel.sendMessage('', {embed: { color: 11316394, description: `${parseInt(Bastion.ping)}ms` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/help/support.js b/modules/help/support.js index ea2edce74..3693384a4 100644 --- a/modules/help/support.js +++ b/modules/help/support.js @@ -25,7 +25,15 @@ exports.run = function(Bastion, message, args) { title: 'Bastion BOT - Support Server', url: 'https://discord.gg/fzx8fkt', description: `Need help or support with Bastion Discord BOT?\nJoin Bastion Support Server for any help you need.\nhttps://discord.gg/fzx8fkt`, - }}); + fields: [ + { + name: 'Website' + value: 'https://bastion.js.org/' + } + ] + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/moderation/addRole.js b/modules/moderation/addRole.js index fba7212f5..c4d8d228d 100644 --- a/modules/moderation/addRole.js +++ b/modules/moderation/addRole.js @@ -37,7 +37,9 @@ exports.run = function(Bastion, message, args) { color: 5088314, title: 'Role Added', description: `**${user.username}**#${user.discriminator} has now been given **${role.name}** role.`, - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/moderation/ban.js b/modules/moderation/ban.js index 8e6432f7a..ee2c43574 100644 --- a/modules/moderation/ban.js +++ b/modules/moderation/ban.js @@ -25,7 +25,9 @@ exports.run = function(Bastion, message, args) { if (!(user = message.mentions.users.first())) return; if (!message.guild.members.get(user.id).bannable) return; - message.guild.members.get(user.id).ban(7); + message.guild.members.get(user.id).ban(7).catch(e => { + Bastion.log.error(e.stack); + }); let reason = args.slice(1).join(' '); if (reason.length < 1) reason = 'No reason given'; @@ -49,12 +51,16 @@ exports.run = function(Bastion, message, args) { inline: false } ] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); user.sendMessage('', {embed: { color: 13380644, title: `Banned from ${message.guild.name} Server`, description: `**Reason:** ${reason}` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/moderation/clear.js b/modules/moderation/clear.js index ceac9d453..4a4927e3f 100644 --- a/modules/moderation/clear.js +++ b/modules/moderation/clear.js @@ -33,6 +33,8 @@ exports.run = function(Bastion, message, args) { message.channel.bulkDelete(msgs).catch(e => { Bastion.log.error(e.stack); }); + }).catch(e => { + Bastion.log.error(e.stack); }); }; diff --git a/modules/moderation/deafen.js b/modules/moderation/deafen.js index 7d55dc367..d691b64a2 100644 --- a/modules/moderation/deafen.js +++ b/modules/moderation/deafen.js @@ -48,7 +48,9 @@ exports.run = function(Bastion, message, args) { inline: false } ] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/moderation/inRole.js b/modules/moderation/inRole.js index f9c85dafd..f90bb9488 100644 --- a/modules/moderation/inRole.js +++ b/modules/moderation/inRole.js @@ -33,7 +33,9 @@ exports.run = function(Bastion, message, args) { color: 6651610, title: `List of Members in ${role.name} role:\n`, description: users.join('\n') - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/moderation/kick.js b/modules/moderation/kick.js index 555db99eb..5331e25e1 100644 --- a/modules/moderation/kick.js +++ b/modules/moderation/kick.js @@ -25,7 +25,9 @@ exports.run = function(Bastion, message, args) { if (!(user = message.mentions.users.first())) return; if (!message.guild.members.get(user.id).kickable) return; - message.guild.members.get(user.id).kick(); + message.guild.members.get(user.id).kick().catch(e => { + Bastion.log.error(e.stack); + }); let reason = args.slice(1).join(' '); if (reason.length < 1) reason = 'No reason given'; @@ -49,12 +51,16 @@ exports.run = function(Bastion, message, args) { inline: false } ] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); user.sendMessage('', {embed: { color: 15451167, title: `Kicked from ${message.guild.name} Server`, description: `**Reason:** ${reason}` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/moderation/mute.js b/modules/moderation/mute.js index 408e724da..ef1b113bb 100644 --- a/modules/moderation/mute.js +++ b/modules/moderation/mute.js @@ -46,7 +46,9 @@ exports.run = function(Bastion, message, args) { inline: false } ] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/moderation/removeRole.js b/modules/moderation/removeRole.js index d6c797b0d..4ef667b99 100644 --- a/modules/moderation/removeRole.js +++ b/modules/moderation/removeRole.js @@ -37,7 +37,9 @@ exports.run = function(Bastion, message, args) { color: 13380644, title: 'Role Removed', description: `**${user.username}**#${user.discriminator} has now been removed from **${role.name}** role.`, - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/moderation/softBan.js b/modules/moderation/softBan.js index 6cf43cd76..56bbafb8d 100644 --- a/modules/moderation/softBan.js +++ b/modules/moderation/softBan.js @@ -25,8 +25,12 @@ exports.run = function(Bastion, message, args) { if (!(user = message.mentions.users.first())) return; if (!message.guild.members.get(user.id).bannable) return; - message.guild.members.get(user.id).ban(7); - message.guild.unban(user.id); + message.guild.members.get(user.id).ban(7).catch(e => { + Bastion.log.error(e.stack); + }); + message.guild.unban(user.id).catch(e => { + Bastion.log.error(e.stack); + }); let reason = args.slice(1).join(' '); if (reason.length < 1) reason = 'No reason given'; @@ -50,12 +54,16 @@ exports.run = function(Bastion, message, args) { inline: false } ] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); user.sendMessage('', {embed: { color: 14845440, title: `Soft-Banned from ${message.guild.name} Server`, description: `**Reason:** ${reason}` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/moderation/unDeafen.js b/modules/moderation/unDeafen.js index bb4eec3a9..521704d81 100644 --- a/modules/moderation/unDeafen.js +++ b/modules/moderation/unDeafen.js @@ -48,7 +48,9 @@ exports.run = function(Bastion, message, args) { inline: false } ] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/moderation/unMute.js b/modules/moderation/unMute.js index 16169b022..bc636dab5 100644 --- a/modules/moderation/unMute.js +++ b/modules/moderation/unMute.js @@ -47,7 +47,9 @@ exports.run = function(Bastion, message, args) { inline: false } ] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/money/betFlip.js b/modules/money/betFlip.js index 575479d65..5ff025086 100644 --- a/modules/money/betFlip.js +++ b/modules/money/betFlip.js @@ -39,25 +39,29 @@ exports.run = function(Bastion, message, args) { if (args[0] > profile.bastionCurrencies) return message.channel.sendMessage('', {embed: { color: 13380644, description: `Unfortunately, you can't bet. You only have **${profile.bastionCurrencies}** Bastion Currencies.` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); if (outcome.toLowerCase() == args[1].toLowerCase()) { prize = args[0] < 50 ? parseInt(args[0])+outcomes.length : args[0] < 100 ? parseInt(args[0])*2 : parseInt(args[0])*3; result = `Congratulations! You won the bet.\nYou won **${prize}** Bastion Flowers.`; sql.run(`UPDATE profiles SET bastionCurrencies=${parseInt(profile.bastionCurrencies)+parseInt(prize)} WHERE userID=${message.author.id}`).catch(e => { Bastion.log.error(e.stack); - });; + }); } else { result = 'Sorry, you lost the bet. Better luck next time.'; sql.run(`UPDATE profiles SET bastionCurrencies=${parseInt(profile.bastionCurrencies)-parseInt(args[0])} WHERE userID=${message.author.id}`).catch(e => { Bastion.log.error(e.stack); - });; + }); } message.channel.sendMessage('', {embed: { color: 6651610, title: `Flipped ${outcome}`, description: result - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/money/betRoll.js b/modules/money/betRoll.js index 53ca63559..b7195ffa6 100644 --- a/modules/money/betRoll.js +++ b/modules/money/betRoll.js @@ -27,7 +27,9 @@ exports.run = function(Bastion, message, args) { if (args[0] < 2) return message.channel.sendMessage('', {embed: { color: 13380644, description: 'Minimum bet amount is 2 Bastion Currencies.' - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); let outcomes = [ 'one', @@ -43,25 +45,29 @@ exports.run = function(Bastion, message, args) { if (args[0] > profile.bastionCurrencies) return message.channel.sendMessage('', {embed: { color: 13380644, description: `Unfortunately, you can't bet. You only have **${profile.bastionCurrencies}** Bastion Currencies.` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); if (outcome.toLowerCase() == args[1].toLowerCase()) { prize = args[0] < 50 ? parseInt(args[0])+outcomes.length : args[0] < 100 ? parseInt(args[0])*2 : parseInt(args[0])*3; result = `Congratulations! You won the bet.\nYou won **${prize}** Bastion Flowers.`; sql.run(`UPDATE profiles SET bastionCurrencies=${parseInt(profile.bastionCurrencies)+parseInt(prize)} WHERE userID=${message.author.id}`).catch(e => { Bastion.log.error(e.stack); - });; + }); } else { result = 'Sorry, you lost the bet. Better luck next time.'; sql.run(`UPDATE profiles SET bastionCurrencies=${parseInt(profile.bastionCurrencies)-parseInt(args[0])} WHERE userID=${message.author.id}`).catch(e => { Bastion.log.error(e.stack); - });; + }); } message.channel.sendMessage('', {embed: { color: 6651610, title: `Rolled :${outcome}:`, description: result - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/money/give.js b/modules/money/give.js index 6e6804a70..a3e2ce764 100644 --- a/modules/money/give.js +++ b/modules/money/give.js @@ -31,7 +31,9 @@ exports.run = function(Bastion, message, args) { else return message.channel.sendMessage('', {embed: { color: 13380644, description: 'You need to mention the user or give their ID to whom you want to give Bastion Currencies.' - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); } if (Bastion.credentials.ownerId.indexOf(message.author.id) > -1) { sql.get(`SELECT bastionCurrencies FROM profiles WHERE userID=${user}`).then(receiver => { @@ -47,11 +49,15 @@ exports.run = function(Bastion, message, args) { message.channel.sendMessage('', {embed: { color: 5088314, description: `You have given <@${user}> **${args[0]}** Bastion Currencies.` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); Bastion.users.get(user).sendMessage('', {embed: { color: 5088314, description: `You have been awarded **${args[0]}** Bastion Currencies from ${message.author}.` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); @@ -62,7 +68,9 @@ exports.run = function(Bastion, message, args) { if (sender.bastionCurrencies < args[0]) return message.channel.sendMessage('', {embed: { color: 13380644, description: `Sorry, unfortunately, you don't have enough Bastion Currencies with you to give it to others.\nYou currently have **${sender.bastionCurrencies}** Bastion Currencies.` - }}) + }}).catch(e => { + Bastion.log.error(e.stack); + }); sql.get(`SELECT bastionCurrencies FROM profiles WHERE userID=${user}`).then(receiver => { if (!receiver) sql.run('INSERT INTO profiles (userID, bastionCurrencies) VALUES (?, ?)', [user, parseInt(args[0])]).catch(e => { @@ -79,11 +87,15 @@ exports.run = function(Bastion, message, args) { message.channel.sendMessage('', {embed: { color: 5088314, description: `You have given <@${user}> **${args[0]}** Bastion Currencies.` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); Bastion.users.get(user).sendMessage('', {embed: { color: 5088314, description: `You have received **${args[0]}** Bastion Currencies from ${message.author}.` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/money/hallOfFame.js b/modules/money/hallOfFame.js index 3461f1ac6..2dec9218c 100644 --- a/modules/money/hallOfFame.js +++ b/modules/money/hallOfFame.js @@ -37,7 +37,9 @@ exports.run = function(Bastion, message, args) { title: 'Hall of Fame', description: `Top ${profiles.length} users with highest Level & Experience Points`, fields: fields - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/money/leaderboard.js b/modules/money/leaderboard.js index 61e958c73..2268e6ce2 100644 --- a/modules/money/leaderboard.js +++ b/modules/money/leaderboard.js @@ -37,7 +37,9 @@ exports.run = function(Bastion, message, args) { title: 'Leaderboard', description: `Top ${profiles.length} users with highest Bastion Currencies`, fields: fields - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/money/profile.js b/modules/money/profile.js index 9c6fe1a00..ee516be99 100644 --- a/modules/money/profile.js +++ b/modules/money/profile.js @@ -64,7 +64,11 @@ exports.run = function(Bastion, message, args) { thumbnail: { url: args.avatarURL } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); + }).catch(e => { + Bastion.log.error(e.stack); }); }; diff --git a/modules/money/take.js b/modules/money/take.js index f58557d83..2fcb97ce6 100644 --- a/modules/money/take.js +++ b/modules/money/take.js @@ -32,7 +32,9 @@ exports.run = function(Bastion, message, args) { else return message.channel.sendMessage('', {embed: { color: 13380644, description: 'You need to mention the user or give their ID to whom you want to charge for penalty.' - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); } let reason; if (args[2]) reason = args.slice(2).join(' '); @@ -52,7 +54,9 @@ exports.run = function(Bastion, message, args) { value: reason } ] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/music/np.js b/modules/music/np.js index 4e08a5042..ad17e62a9 100644 --- a/modules/music/np.js +++ b/modules/music/np.js @@ -20,7 +20,9 @@ */ exports.run = function(Bastion, message, args) { - message.delete(); + message.delete().catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/music/pause.js b/modules/music/pause.js index 111dfccd0..9325628da 100644 --- a/modules/music/pause.js +++ b/modules/music/pause.js @@ -20,7 +20,9 @@ */ exports.run = function(Bastion, message, args) { - message.delete(); + message.delete().catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/music/play.js b/modules/music/play.js index 5139bd209..a63c316e7 100644 --- a/modules/music/play.js +++ b/modules/music/play.js @@ -26,7 +26,9 @@ let queue = {}; exports.run = function(Bastion, message, args) { // TODO: Auto pause/resume playback - message.delete(); + message.delete().catch(e => { + Bastion.log.error(e.stack); + }); if (args.length < 1) return; sql.get(`SELECT musicTextChannelID, musicVoiceChannelID FROM guildSettings WHERE guildID=${message.guild.id}`).then(musicChannel => { if (message.guild.voiceConnection) { @@ -38,18 +40,28 @@ exports.run = function(Bastion, message, args) { if (!(voiceChannel = message.guild.channels.filter(c => c.type == 'voice').get(musicChannel.musicVoiceChannelID)) || !(textChannel = message.guild.channels.filter(c => c.type == 'text').get(musicChannel.musicTextChannelID))) return message.channel.sendMessage('', {embed: { color: 13380644, description: 'Invalid Text/Voice Channel ID has been added to default music channel.' - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); vcStats = `You need to be in the default music channel (**${voiceChannel.name}**) of the BOT to be able to use music commands.`; } else return message.channel.sendMessage('', {embed: { color: 13380644, description: 'No default music channel has been set. And I need to be in a voice channel to be able to play music.' - }}).then(m => m.delete(30000)); + }}).then(m => { + m.delete(30000); + }).catch(e => { + Bastion.log.error(e.stack); + }); if (textChannel != message.channel) return; if (voiceChannel.members.get(message.author.id) == undefined) return message.channel.sendMessage('', {embed: { color: 13380644, description: vcStats - }}).then(m => m.delete(30000)); + }}).then(m => { + m.delete(30000); + }).catch(e => { + Bastion.log.error(e.stack); + }); args = /^((https:\/\/)(www\.)?(youtube\.com)\/watch\?v=[a-zA-Z0-9-_]{11})$/i.test(args[0]) ? args[0] : 'ytsearch:' + args.join(' '); yt.getInfo(args, ['-q', '--no-warnings', '--force-ipv4', '--format=bestvideo[height<=480]+bestaudio/best[height<=480]'], (err, info) => { @@ -72,7 +84,11 @@ exports.run = function(Bastion, message, args) { footer: { text: `Position: ${queue[message.guild.id].songs.length} | Duration: ${info.duration} | Requester: ${message.author.username}#${message.author.discriminator}` } - }}).then(m => m.delete(30000)); + }}).then(m => { + m.delete(30000); + }).catch(e => { + Bastion.log.error(e.stack); + }); if (queue.hasOwnProperty(message.guild.id) && (queue[message.guild.id].playing == true)) return; if (!message.guild.voiceConnection) { @@ -85,6 +101,8 @@ exports.run = function(Bastion, message, args) { queue[message.guild.id].playing = false; voiceChannel.leave(); m.delete(10000); + }).catch(e => { + Bastion.log.error(e.stack); }); dispatcher = message.guild.voiceConnection.playStream(yt(song.url), { passes: 1 }); queue[message.guild.id].playing = true; @@ -98,7 +116,11 @@ exports.run = function(Bastion, message, args) { footer: { text: `🔉 ${dispatcher.volume*50}% | Duration: ${info.duration} | Requester: ${message.author.username}#${message.author.discriminator}` } - }}).then(m => m.delete(30000)); + }}).then(m => { + m.delete(30000); + }).catch(e => { + Bastion.log.error(e.stack); + }); let collector = textChannel.createCollector( msg => msg.content.startsWith(`${Bastion.config.prefix}pause`) || msg.content.startsWith(`${Bastion.config.prefix}resume`) || msg.content.startsWith(`${Bastion.config.prefix}skip`) || msg.content.startsWith(`${Bastion.config.prefix}stop`) || msg.content.startsWith(`${Bastion.config.prefix}volume`) || msg.content.startsWith(`${Bastion.config.prefix}np`) || msg.content.startsWith(`${Bastion.config.prefix}queue`) @@ -117,6 +139,8 @@ exports.run = function(Bastion, message, args) { }}).then(m => { dispatcher.pause(); m.delete(30000); + }).catch(e => { + Bastion.log.error(e.stack); }); } else if (msg.content.startsWith(`${Bastion.config.prefix}resume`)) { @@ -131,7 +155,9 @@ exports.run = function(Bastion, message, args) { } }}).then(m => { dispatcher.resume(); - m.delete(30000) + m.delete(30000); + }).catch(e => { + Bastion.log.error(e.stack); }); } else if (msg.content.startsWith(`${Bastion.config.prefix}skip`)) { @@ -142,6 +168,8 @@ exports.run = function(Bastion, message, args) { }}).then(m => { dispatcher.end(); m.delete(10000); + }).catch(e => { + Bastion.log.error(e.stack); }); } else if (msg.content.startsWith(`${Bastion.config.prefix}stop`)) { @@ -153,6 +181,8 @@ exports.run = function(Bastion, message, args) { if (queue.hasOwnProperty(message.guild.id)) queue[message.guild.id].songs = []; voiceChannel.leave(); m.delete(10000); + }).catch(e => { + Bastion.log.error(e.stack); }); } else if (msg.content.startsWith(`${Bastion.config.prefix}volume`)) { @@ -169,7 +199,11 @@ exports.run = function(Bastion, message, args) { textChannel.sendMessage('', {embed: { color: 5088314, description: `Volume: ${Math.round(dispatcher.volume*50)}%` - }}).then(m => m.delete(10000)); + }}).then(m => { + m.delete(10000) + }).catch(e => { + Bastion.log.error(e.stack); + }); } else if (msg.content.startsWith(`${Bastion.config.prefix}np`)) { textChannel.sendMessage('', {embed: { @@ -182,7 +216,11 @@ exports.run = function(Bastion, message, args) { footer: { text: `🔉 ${dispatcher.volume*50}% | ${Math.floor(dispatcher.time / 60000)}:${Math.floor((dispatcher.time % 60000)/1000) <10 ? '0'+Math.floor((dispatcher.time % 60000)/1000) : Math.floor((dispatcher.time % 60000)/1000)} / ${info.duration}` } - }}).then(m => m.delete(30000)); + }}).then(m => { + m.delete(30000) + }).catch(e => { + Bastion.log.error(e.stack); + }); } else if (msg.content.startsWith(`${Bastion.config.prefix}queue`)) { let fields = []; @@ -199,7 +237,11 @@ exports.run = function(Bastion, message, args) { footer: { text: `Total no. of songs in queue: ${queue[message.guild.id].songs.length-1}` } - }}).then(m => m.delete(60000)); + }}).then(m => { + m.delete(60000); + }).catch(e => { + Bastion.log.error(e.stack); + }); } }); dispatcher.on('end', () => { @@ -217,6 +259,8 @@ exports.run = function(Bastion, message, args) { }); } }); + }).catch(e => { + Bastion.log.error(e.stack); }); }; diff --git a/modules/music/queue.js b/modules/music/queue.js index 3f6c49ba3..7c902bc29 100644 --- a/modules/music/queue.js +++ b/modules/music/queue.js @@ -20,7 +20,9 @@ */ exports.run = function(Bastion, message, args) { - message.delete(); + message.delete().catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/music/resume.js b/modules/music/resume.js index 277559714..505730405 100644 --- a/modules/music/resume.js +++ b/modules/music/resume.js @@ -20,7 +20,9 @@ */ exports.run = function(Bastion, message, args) { - message.delete(); + message.delete().catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/music/skip.js b/modules/music/skip.js index 4d60141a1..a6bae9b24 100644 --- a/modules/music/skip.js +++ b/modules/music/skip.js @@ -20,7 +20,9 @@ */ exports.run = function(Bastion, message, args) { - message.delete(); + message.delete().catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/music/stop.js b/modules/music/stop.js index 831ce572c..e8c2576cd 100644 --- a/modules/music/stop.js +++ b/modules/music/stop.js @@ -20,7 +20,9 @@ */ exports.run = function(Bastion, message, args) { - message.delete(); + message.delete().catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/music/summon.js b/modules/music/summon.js index 029576b5c..97bb26522 100644 --- a/modules/music/summon.js +++ b/modules/music/summon.js @@ -28,15 +28,21 @@ exports.run = function(Bastion, message, args) { if (!voiceChannel || voiceChannel.type !== 'voice') return message.channel.sendMessage('', {embed: { color: 13380644, description: `I can't join your voice channel <@${message.author.id}>.` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); if (voiceChannel.joinable) voiceChannel.join().then(connection => { - message.guild.members.get(Bastion.user.id).setDeaf(true); + message.guild.members.get(Bastion.user.id).setDeaf(true).catch(e => { + Bastion.log.error(e.stack); + }); if (!voiceChannel.speakable) { voiceChannel.leave(); message.channel.sendMessage('', {embed: { color: 13380644, description: 'I don\'t have permissions to speak in this channel.' - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); } }); } @@ -46,19 +52,27 @@ exports.run = function(Bastion, message, args) { if (!musicChannel.musicVoiceChannelID) return message.channel.sendMessage('', {embed: { color: 13380644, description: 'No default music channel has been set. So, only the bot owner can use this command.' - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); if (!(voiceChannel = message.guild.channels.filter(c => c.type == 'voice').get(musicChannel.musicVoiceChannelID))) return message.channel.sendMessage('', {embed: { color: 13380644, description: `I can't join your voice channel <@${message.author.id}>.` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); if (voiceChannel.joinable) voiceChannel.join().then(connection => { - message.guild.members.get(Bastion.user.id).setDeaf(true); + message.guild.members.get(Bastion.user.id).setDeaf(true).catch(e => { + Bastion.log.error(e.stack); + }); if (!voiceChannel.speakable) { voiceChannel.leave(); message.channel.sendMessage('', {embed: { color: 13380644, description: 'I don\'t have permissions to speak in this channel.' - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); } }); }); diff --git a/modules/music/volume.js b/modules/music/volume.js index adeb733ff..ea606c746 100644 --- a/modules/music/volume.js +++ b/modules/music/volume.js @@ -20,7 +20,9 @@ */ exports.run = function(Bastion, message, args) { - message.delete(); + message.delete().catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/owner/addMusicChannel.js b/modules/owner/addMusicChannel.js index 2d0e06c18..2199caaae 100644 --- a/modules/owner/addMusicChannel.js +++ b/modules/owner/addMusicChannel.js @@ -39,7 +39,9 @@ exports.run = function(Bastion, message, args) { value: message.guild.channels.filter(c => c.type == 'voice').get(args[0]) ? message.guild.channels.filter(c => c.type == 'voice').get(args[0]).name : 'Invalid' } ] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/owner/addTrigger.js b/modules/owner/addTrigger.js index f9d703551..4467837d3 100644 --- a/modules/owner/addTrigger.js +++ b/modules/owner/addTrigger.js @@ -28,7 +28,9 @@ exports.run = function(Bastion, message, args) { args = args.join(' ') if (!/.+ << .+/.test(args)) return; args = args.split(' << '); - sql.run('INSERT INTO triggers (trigger, response) VALUES (?, ?)', [args[0], args[1]]); + sql.run('INSERT INTO triggers (trigger, response) VALUES (?, ?)', [args[0], args[1]]).catch(e => { + Bastion.log.error(e.stack); + });; message.channel.sendMessage('', {embed: { color: 5088314, @@ -43,7 +45,9 @@ exports.run = function(Bastion, message, args) { value: args[1] } ] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/owner/announce.js b/modules/owner/announce.js index 7d37cb8f6..b35d661b8 100644 --- a/modules/owner/announce.js +++ b/modules/owner/announce.js @@ -34,7 +34,9 @@ exports.run = function(Bastion, message, args) { color: 5088314, title: 'Announced', description: args.join(' ') - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/owner/deleteTriggers.js b/modules/owner/deleteTriggers.js index 9e7d55ffd..aeeb01984 100644 --- a/modules/owner/deleteTriggers.js +++ b/modules/owner/deleteTriggers.js @@ -31,7 +31,9 @@ exports.run = function(Bastion, message, args) { color: 13380644, title: 'Trigger deleted', description: args.join(' ') - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/owner/leave.js b/modules/owner/leave.js index e796d96cc..478712186 100644 --- a/modules/owner/leave.js +++ b/modules/owner/leave.js @@ -22,7 +22,9 @@ exports.run = function(Bastion, message, args) { if (Bastion.credentials.ownerId.indexOf(message.author.id) < 0) return Bastion.log.info('You don\'t have permissions to use this command.'); if (!/^[0-9]{18}$/.test(args[0])) return; - if (Bastion.guilds.get(args[0]).available) Bastion.guilds.get(args[0]).leave(); + if (Bastion.guilds.get(args[0]).available) Bastion.guilds.get(args[0]).leave().catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/owner/listTriggers.js b/modules/owner/listTriggers.js index 094379abe..ca25abcd7 100644 --- a/modules/owner/listTriggers.js +++ b/modules/owner/listTriggers.js @@ -30,7 +30,9 @@ exports.run = function(Bastion, message, args) { color: 5088314, title: 'List of triggers', description: triggers.map(t => t.trigger).join('\n\n') - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/owner/messageUser.js b/modules/owner/messageUser.js index 5ae4e0e46..048533f5e 100644 --- a/modules/owner/messageUser.js +++ b/modules/owner/messageUser.js @@ -23,14 +23,13 @@ exports.run = function(Bastion, message, args) { if (Bastion.credentials.ownerId.indexOf(message.author.id) < 0) return Bastion.log.info('You don\'t have permissions to use this command.'); if (!/^[0-9]{18}$/.test(args[0])) return; - if (Bastion.users.get(args[0])) { + if (Bastion.users.get(args[0])) Bastion.users.get(args[0]).sendMessage('', {embed: { color: 6651610, description: args.slice(1).join(' ') }}).catch(e => { Bastion.log.error(e.stack); }); - } }; exports.conf = { diff --git a/modules/owner/setAvatar.js b/modules/owner/setAvatar.js index b2f5c90a8..c9d096d5c 100644 --- a/modules/owner/setAvatar.js +++ b/modules/owner/setAvatar.js @@ -28,7 +28,11 @@ exports.run = function(Bastion, message, args) { message.channel.sendMessage('', {embed: { color: 14211540, description: `${Bastion.user.username}'s avatar changed!` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); + }).catch(e => { + Bastion.log.error(e.stack); }); } }; diff --git a/modules/owner/setGame.js b/modules/owner/setGame.js index c226ad89e..133eef5c5 100644 --- a/modules/owner/setGame.js +++ b/modules/owner/setGame.js @@ -23,14 +23,20 @@ exports.run = function(Bastion, message, args) { if (Bastion.credentials.ownerId.indexOf(message.author.id) < 0) return Bastion.log.info('You don\'t have permissions to use this command.'); if (args.length >= 1) { - Bastion.user.setGame(args.join(' ')); + Bastion.user.setGame(args.join(' ')).catch(e => { + Bastion.log.error(e.stack); + }); message.channel.sendMessage('', {embed: { color: 14211540, description: `${Bastion.user.username}'s game is now set to **${args.join(' ')}**` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); } else { - Bastion.user.setGame(Bastion.config.game) + Bastion.user.setGame(Bastion.config.game).catch(e => { + Bastion.log.error(e.stack); + }); } }; diff --git a/modules/owner/setStatus.js b/modules/owner/setStatus.js index 913e590ae..3410c265f 100644 --- a/modules/owner/setStatus.js +++ b/modules/owner/setStatus.js @@ -23,14 +23,20 @@ exports.run = function(Bastion, message, args) { if (Bastion.credentials.ownerId.indexOf(message.author.id) < 0) return Bastion.log.info('You don\'t have permissions to use this command.'); if (args.length >= 1 && (args == 'online' || args == 'idle' || args == 'dnd' || args == 'invisible') ) { - Bastion.user.setStatus(args.join(' ')); + Bastion.user.setStatus(args.join(' ')).catch(e => { + Bastion.log.error(e.stack); + }); message.channel.sendMessage('', {embed: { color: 14211540, description: `${Bastion.user.username}'s status is now set to **${args.join(' ')}**` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); } else { - Bastion.user.setStatus(Bastion.config.status); + Bastion.user.setStatus(Bastion.config.status).catch(e => { + Bastion.log.error(e.stack); + }); } }; diff --git a/modules/owner/setStream.js b/modules/owner/setStream.js index 971a20b8a..26d6d666e 100644 --- a/modules/owner/setStream.js +++ b/modules/owner/setStream.js @@ -21,14 +21,17 @@ exports.run = function(Bastion, message, args) { if (Bastion.credentials.ownerId.indexOf(message.author.id) < 0) return Bastion.log.info('You don\'t have permissions to use this command.'); - if (!/^((https:\/\/)(www\.)?(twitch\.tv)\/[a-z0-9-._]+)$/i.test(args[0]) || args.slice(1).join(' ').length < 1) return; - Bastion.user.setGame(args.slice(1).join(' '), args[0]); + Bastion.user.setGame(args.slice(1).join(' '), args[0]).catch(e => { + Bastion.log.error(e.stack); + }); message.channel.sendMessage('', {embed: { color: 14211540, description: `${Bastion.user.username} is now streaming **${args.slice(1).join(' ')}**` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/owner/setUsername.js b/modules/owner/setUsername.js index d5626e4b9..ebd6f094d 100644 --- a/modules/owner/setUsername.js +++ b/modules/owner/setUsername.js @@ -23,11 +23,15 @@ exports.run = function(Bastion, message, args) { if (Bastion.credentials.ownerId.indexOf(message.author.id) < 0) return Bastion.log.info('You don\'t have permissions to use this command.'); if (args.join(' ').length >= 1) { - Bastion.user.setUsername(args.join(' ')); + Bastion.user.setUsername(args.join(' ')).catch(e => { + Bastion.log.error(e.stack); + }); message.channel.sendMessage('', {embed: { color: 14211540, description: `${Bastion.user.username}'s username is now set to **${args.join(' ')}**` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); } }; diff --git a/modules/owner/shutdown.js b/modules/owner/shutdown.js index 6c68d0066..7f7324ca8 100644 --- a/modules/owner/shutdown.js +++ b/modules/owner/shutdown.js @@ -25,9 +25,13 @@ exports.run = function(Bastion, message, args) { message.channel.sendMessage('', {embed: { color: 11316394, description: 'GoodBye :wave:! See you soon.' - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); - Bastion.destroy(); + Bastion.destroy().catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/owner/userBlacklist.js b/modules/owner/userBlacklist.js index 53243735b..26196cb97 100644 --- a/modules/owner/userBlacklist.js +++ b/modules/owner/userBlacklist.js @@ -42,7 +42,7 @@ exports.run = function(Bastion, message, args) { Bastion.log.error(e.stack); }); } - title = 'Added to blacklisted users' + title = 'Added to blacklisted users'; } else if (/^(remove|rem|-)$/i.test(args[0])) { for (var i = 0; i < user.length; i++) { @@ -51,14 +51,16 @@ exports.run = function(Bastion, message, args) { Bastion.log.error(e.stack); }); } - title = 'Removed from blacklisted users' + title = 'Removed from blacklisted users'; } else return; message.channel.sendMessage('', {embed: { color: 13380644, title: title, description: user.join(', ') - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }).catch(e => { Bastion.log.error(e.stack); }); diff --git a/modules/queries/ask.js b/modules/queries/ask.js index 4526bda0f..635eecc9c 100644 --- a/modules/queries/ask.js +++ b/modules/queries/ask.js @@ -31,29 +31,31 @@ exports.run = function(Bastion, message, args) { title: args.join(' '), description: 'React to this message with :one: to vote **YES**\n\nReact to this message with :zero: to vote **NO**' }}).then(m => { - for (var i = 0; i < opt.length; i++) m.react(opt[i]) - setTimeout(function () { - let res = []; - for (var i = 0; i < opt.length; i++) - res.push(m.reactions.get(opt[i]).users.size - 1); - message.channel.sendMessage('', {embed: { - color: 5088314, - title: args.join(' '), - fields: [ - { - name: 'Yes', - value: res[1], - inline: true - }, - { - name: 'No', - value: res[0], - inline: true - } - ] - }}); - }, 60000); - }); + for (var i = 0; i < opt.length; i++) m.react(opt[i]) + setTimeout(function () { + let res = []; + for (var i = 0; i < opt.length; i++) + res.push(m.reactions.get(opt[i]).users.size - 1); + message.channel.sendMessage('', {embed: { + color: 5088314, + title: args.join(' '), + fields: [ + { + name: 'Yes', + value: res[1], + inline: true + }, + { + name: 'No', + value: res[0], + inline: true + } + ] + }}); + }, 60000); + }).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/avatar.js b/modules/queries/avatar.js index 72aa7779b..f076ad254 100644 --- a/modules/queries/avatar.js +++ b/modules/queries/avatar.js @@ -37,7 +37,9 @@ exports.run = function(Bastion, message, args) { image: { url: user.avatarURL } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/calculate.js b/modules/queries/calculate.js index 651086c40..68855fb6d 100644 --- a/modules/queries/calculate.js +++ b/modules/queries/calculate.js @@ -34,7 +34,9 @@ exports.run = function(Bastion, message, args) { message.channel.sendMessage('', {embed: { color: 13380644, description: 'Invalid mathematical expression!' - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); } }; diff --git a/modules/queries/catFact.js b/modules/queries/catFact.js index 588b1ff18..978d938be 100644 --- a/modules/queries/catFact.js +++ b/modules/queries/catFact.js @@ -27,7 +27,9 @@ exports.run = function(Bastion, message, args) { color: 6651610, title: 'Cat Fact:', description: catFacts[getRandomInt(0, catFacts.length -1)] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/channelID.js b/modules/queries/channelID.js index 08de66f41..cb30cb563 100644 --- a/modules/queries/channelID.js +++ b/modules/queries/channelID.js @@ -36,7 +36,9 @@ exports.run = function(Bastion, message, args) { inline: true } ] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/channelInfo.js b/modules/queries/channelInfo.js index 6e7207bd3..0b3ca48aa 100644 --- a/modules/queries/channelInfo.js +++ b/modules/queries/channelInfo.js @@ -52,7 +52,9 @@ exports.run = function(Bastion, message, args) { inline: true } ] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/channelTopic.js b/modules/queries/channelTopic.js index b0d9ff2f8..b1cf56ace 100644 --- a/modules/queries/channelTopic.js +++ b/modules/queries/channelTopic.js @@ -26,7 +26,9 @@ exports.run = function(Bastion, message, args) { color: 6651610, title: 'Channel Topic', description: (channel.topic == null || channel.topic.length < 1) ? 'No channel topic set' : channel.topic - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/choose.js b/modules/queries/choose.js index 69d599c51..72d13dcef 100644 --- a/modules/queries/choose.js +++ b/modules/queries/choose.js @@ -24,7 +24,9 @@ exports.run = function(Bastion, message, args) { color: 6651610, title: 'In my opinion', description: args.join(' ').split('/')[Math.floor(Math.random()*args.join(' ').split('/').length)], - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/color.js b/modules/queries/color.js index 0e52e1f75..8f37577b0 100644 --- a/modules/queries/color.js +++ b/modules/queries/color.js @@ -101,7 +101,9 @@ exports.run = function(Bastion, message, args) { thumbnail: { url: `https://dummyimage.com/250/${args[0].indexOf('#') != -1 ? args[0].split('#').slice(1).join() : args[0]}/&text=%20` } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/crimeCoefficient.js b/modules/queries/crimeCoefficient.js index 1a74de9f4..07cbb616e 100644 --- a/modules/queries/crimeCoefficient.js +++ b/modules/queries/crimeCoefficient.js @@ -35,7 +35,9 @@ exports.run = function(Bastion, message, args) { color: 6651610, title: `Crime Coefficient of ${user} is ${crimeCoefficient}`, description: crimeStat - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/define.js b/modules/queries/define.js index 5aed62dcb..21fe25956 100644 --- a/modules/queries/define.js +++ b/modules/queries/define.js @@ -49,7 +49,9 @@ exports.run = function(Bastion, message, args) { } }}; } - message.channel.sendMessage('', embed); + message.channel.sendMessage('', embed).catch(e => { + Bastion.log.error(e.stack); + }); }); }; diff --git a/modules/queries/echo.js b/modules/queries/echo.js index 63db64155..0a3e209de 100644 --- a/modules/queries/echo.js +++ b/modules/queries/echo.js @@ -23,7 +23,9 @@ exports.run = function(Bastion, message, args) { message.channel.sendMessage('', {embed: { color: 11316394, description: args.join(' ') - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/flipText.js b/modules/queries/flipText.js index 9a34bbc83..ec5acfec1 100644 --- a/modules/queries/flipText.js +++ b/modules/queries/flipText.js @@ -27,13 +27,15 @@ exports.run = function(Bastion, message, args) { args = args.join(' '); for (var i = 0; i < Object.keys(flipText).length; i++) - args = args.replace(Object.keys(flipText)[i], flipText[Object.keys(flipText)[i]]); + args = args.replace(Object.keys(flipText)[i], flipText[Object.keys(flipText)[i]]); message.channel.sendMessage('', {embed: { color: 6651610, title: 'Flipped Text:', description: reverseString(args) - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/forecast.js b/modules/queries/forecast.js index b84b3b610..5bf4f8ff7 100644 --- a/modules/queries/forecast.js +++ b/modules/queries/forecast.js @@ -43,7 +43,9 @@ exports.run = function(Bastion, message, args) { text: 'Powered by MSN Weather', icon_url: 'https://compass-ssl.microsoft.com/assets/97/01/97013f72-b153-4c69-ab73-a7416cb126b5.png?n=weather-png.png' } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }); }; diff --git a/modules/queries/fortune.js b/modules/queries/fortune.js index 820c7e73c..d3c9f590e 100644 --- a/modules/queries/fortune.js +++ b/modules/queries/fortune.js @@ -27,7 +27,9 @@ exports.run = function(Bastion, message, args) { color: 6651610, title: 'Fortune:', description: fortuneCookies[getRandomInt(0, fortuneCookies.length -1)] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/imdb.js b/modules/queries/imdb.js index cec03c670..3be030142 100644 --- a/modules/queries/imdb.js +++ b/modules/queries/imdb.js @@ -82,7 +82,9 @@ exports.run = function(Bastion, message, args) { icon_url: 'https://pbs.twimg.com/profile_images/780796992611942405/qj7ytv9v.jpg', text: 'Powered by IMDb' } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }); }; diff --git a/modules/queries/leet.js b/modules/queries/leet.js index 70af49cdc..58193646e 100644 --- a/modules/queries/leet.js +++ b/modules/queries/leet.js @@ -34,7 +34,9 @@ exports.run = function(Bastion, message, args) { color: 6651610, title: 'Leet Text', description: args - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/lmgtfy.js b/modules/queries/lmgtfy.js index 65f647ef5..8267e7a23 100644 --- a/modules/queries/lmgtfy.js +++ b/modules/queries/lmgtfy.js @@ -30,7 +30,9 @@ exports.run = function(Bastion, message, args) { footer: { text: 'Powered by lmgtfy' } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/morseCode.js b/modules/queries/morseCode.js index 987934e92..ce421f57a 100644 --- a/modules/queries/morseCode.js +++ b/modules/queries/morseCode.js @@ -87,7 +87,9 @@ exports.run = function(Bastion, message, args) { color: 6651610, title: 'Morse Code', description: `**${args}**` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/overwatch.js b/modules/queries/overwatch.js index 0dee0f658..f99b36adb 100644 --- a/modules/queries/overwatch.js +++ b/modules/queries/overwatch.js @@ -83,7 +83,9 @@ exports.run = function(Bastion, message, args) { }}; } } - message.channel.sendMessage('', embed); + message.channel.sendMessage('', embed).catch(e => { + Bastion.log.error(e.stack); + }); }); }; diff --git a/modules/queries/poll.js b/modules/queries/poll.js index 6dcb07380..b5505bfcb 100644 --- a/modules/queries/poll.js +++ b/modules/queries/poll.js @@ -49,7 +49,9 @@ exports.run = function(Bastion, message, args) { footer: { text: `To get help with voting, type: ${Bastion.config.prefix}help vote` } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); votes.on('message', m => { if ((m.content.startsWith(`${Bastion.config.prefix}endpoll`) || m.content.startsWith(`${Bastion.config.prefix}pollend`)) && (m.author.id == message.author.id)) votes.stop(); @@ -59,7 +61,9 @@ exports.run = function(Bastion, message, args) { description: `**+1 Vote:** ${args[i]}` }}).then(v => { v.delete(); - m.delete(); + m.delete().catch(e => { + Bastion.log.error(e.stack); + }); }); }); votes.on('end', pollRes => { @@ -84,9 +88,11 @@ exports.run = function(Bastion, message, args) { title: 'Poll Result', description: args[0], fields: result - }}).then( + }}).then(() => { activeChannels=activeChannels.slice(activeChannels.indexOf(message.channel.id)+1, 1) - ); + }).catch(e => { + Bastion.log.error(e.stack); + }); }); } else { diff --git a/modules/queries/quotes.js b/modules/queries/quotes.js index 9fccf0f4b..ff436a34d 100644 --- a/modules/queries/quotes.js +++ b/modules/queries/quotes.js @@ -41,7 +41,9 @@ exports.run = function(Bastion, message, args) { footer: { text: `Quote: ${index}` } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/reverse.js b/modules/queries/reverse.js index 22231005f..df4a3cc53 100644 --- a/modules/queries/reverse.js +++ b/modules/queries/reverse.js @@ -28,7 +28,9 @@ exports.run = function(Bastion, message, args) { color: 6651610, title: 'Reversed Text:', description: reverseString(args.join(' ')) - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/roles.js b/modules/queries/roles.js index e44fb0faf..ce88d1f18 100644 --- a/modules/queries/roles.js +++ b/modules/queries/roles.js @@ -33,7 +33,9 @@ exports.run = function(Bastion, message, args) { color: 6651610, title: 'List of Roles', fields: fields - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/serverID.js b/modules/queries/serverID.js index 961933911..34dd5a070 100644 --- a/modules/queries/serverID.js +++ b/modules/queries/serverID.js @@ -24,7 +24,9 @@ exports.run = function(Bastion, message, args) { color: 6651610, title: 'Server ID', description: message.guild.id - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/serverInfo.js b/modules/queries/serverInfo.js index be516a677..9f9add621 100644 --- a/modules/queries/serverInfo.js +++ b/modules/queries/serverInfo.js @@ -78,7 +78,9 @@ exports.run = function(Bastion, message, args) { thumbnail: { url: message.guild.iconURL } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/sweep.js b/modules/queries/sweep.js index c85b6bff1..b731972cb 100644 --- a/modules/queries/sweep.js +++ b/modules/queries/sweep.js @@ -39,7 +39,9 @@ exports.run = function(Bastion, message, args) { inline: true } ] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/tapCode.js b/modules/queries/tapCode.js index ba365df8e..cc0dc7b95 100644 --- a/modules/queries/tapCode.js +++ b/modules/queries/tapCode.js @@ -61,7 +61,9 @@ exports.run = function(Bastion, message, args) { color: 6651610, title: 'Tap Code', description: `**${args}**` - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/translate.js b/modules/queries/translate.js index 1cd7329fa..55ab21093 100644 --- a/modules/queries/translate.js +++ b/modules/queries/translate.js @@ -31,7 +31,9 @@ exports.run = function(Bastion, message, args) { text: `Powered by Google Translate | Translation from ${res.from.language.iso.toUpperCase()} to ${args[0].toUpperCase()}`, icon_url: 'https://upload.wikimedia.org/wikipedia/commons/d/db/Google_Translate_Icon.png' } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }); }; diff --git a/modules/queries/urbanDictionary.js b/modules/queries/urbanDictionary.js index 48947e8db..e9c99c008 100644 --- a/modules/queries/urbanDictionary.js +++ b/modules/queries/urbanDictionary.js @@ -46,7 +46,9 @@ exports.run = function(Bastion, message, args) { }}; } - message.channel.sendMessage('', embed); + message.channel.sendMessage('', embed).catch(e => { + Bastion.log.error(e.stack); + }); }); }; diff --git a/modules/queries/userID.js b/modules/queries/userID.js index 3a20ec639..c76d1b3f3 100644 --- a/modules/queries/userID.js +++ b/modules/queries/userID.js @@ -36,7 +36,9 @@ exports.run = function(Bastion, message, args) { inline: true } ] - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/userInfo.js b/modules/queries/userInfo.js index ef6eec53a..94c33b225 100644 --- a/modules/queries/userInfo.js +++ b/modules/queries/userInfo.js @@ -91,7 +91,9 @@ exports.run = function(Bastion, message, args) { thumbnail: { url: user.avatarURL } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }; exports.conf = { diff --git a/modules/queries/weather.js b/modules/queries/weather.js index e66fa4400..5014a1dfe 100644 --- a/modules/queries/weather.js +++ b/modules/queries/weather.js @@ -95,7 +95,9 @@ exports.run = function(Bastion, message, args) { text: 'Powered by MSN Weather', icon_url: 'https://compass-ssl.microsoft.com/assets/97/01/97013f72-b153-4c69-ab73-a7416cb126b5.png?n=weather-png.png' } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }); }; diff --git a/modules/queries/wikipedia.js b/modules/queries/wikipedia.js index fb967b683..288c77a12 100644 --- a/modules/queries/wikipedia.js +++ b/modules/queries/wikipedia.js @@ -44,7 +44,9 @@ exports.run = function(Bastion, message, args) { } }}; } - message.channel.sendMessage('', embed); + message.channel.sendMessage('', embed).catch(e => { + Bastion.log.error(e.stack); + }); }); }; diff --git a/modules/queries/xkcd.js b/modules/queries/xkcd.js index 2b20c1e43..31bf285c4 100644 --- a/modules/queries/xkcd.js +++ b/modules/queries/xkcd.js @@ -51,7 +51,9 @@ exports.run = function(Bastion, message, args) { text: 'Powered by xkcd', icon_url: 'https://cdn.shopify.com/s/files/1/0149/3544/products/hoodie_1_7f9223f9-6933-47c6-9af5-d06b8227774a_1024x1024.png?v=1479786341' } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }); }); } @@ -81,7 +83,9 @@ exports.run = function(Bastion, message, args) { text: 'Powered by xkcd', icon_url: 'https://cdn.shopify.com/s/files/1/0149/3544/products/hoodie_1_7f9223f9-6933-47c6-9af5-d06b8227774a_1024x1024.png?v=1479786341' } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }); } else { @@ -112,7 +116,9 @@ exports.run = function(Bastion, message, args) { text: 'Powered by xkcd', icon_url: 'https://cdn.shopify.com/s/files/1/0149/3544/products/hoodie_1_7f9223f9-6933-47c6-9af5-d06b8227774a_1024x1024.png?v=1479786341' } - }}); + }}).catch(e => { + Bastion.log.error(e.stack); + }); }); }); } diff --git a/package.json b/package.json index 03221e285..3cbfa8809 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "bastion", - "version": "1.0.1", + "version": "1.1.0", "description": "Bastion: A Discord BOT that can do Administration, Moderation, Searches, can play Music, Games, has a good sense of Humor and can even talk with you!", - "url": "https://github.com/snkrsnkampa/Bastion", + "url": "https://bastion.js.org/", "main": "bot.js", "scripts": { "start": "node bot.js" diff --git a/run.sh b/run.sh index 6dafa5efd..fdfd39ea6 100755 --- a/run.sh +++ b/run.sh @@ -8,6 +8,13 @@ RED='\033[0;31m' GREEN='\033[0;32m' CYAN='\033[0;36m' +if [ "$(id -u)" != "0" ]; then + echo -e "${CYAN}[Bastion]: ${ORANGE}[ERROR] Bastion BOT Installer requires root permissions.${NC}" + hash sudo &>/dev/null || (echo -e "${CYAN}[Bastion]: ${NC} Run this installer with root permissions.\n" && exit 1) + sudo ./run.sh + exit 1 +fi + echo -e "${CYAN}[Bastion]:${NC} Checking System..." echo diff --git a/update.cmd b/update.cmd new file mode 100644 index 000000000..7ab4df528 --- /dev/null +++ b/update.cmd @@ -0,0 +1,29 @@ +@ECHO off +TITLE Bastion BOT +CLS +COLOR 0F +ECHO. + +SET cwd=%~dp0 + +IF EXIST node_modules ( + ECHO [Bastion]: Deleting old dependencies... + RD /S /Q node_modules + ECHO [Bastion]: Done. +) +ECHO [Bastion]: Installing new dependencies... +npm install &>nul +npm install -g ffmpeg-binaries &>nul +ECHO [Bastion]: Done. +ECHO [Bastion]: Ready to boot up and start running. +ECHO. + +EXIT /B 0 + +:EXIT +ECHO. +ECHO [Bastion]: Press any key to exit. +PAUSE &>nul +CD /D "%cwd%" +TITLE Windows Command Prompt (CMD) +COLOR diff --git a/update.sh b/update.sh new file mode 100644 index 000000000..a7bdd75d4 --- /dev/null +++ b/update.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -e + +reset + +NC='\033[0m' +RED='\033[0;31m' +GREEN='\033[0;32m' +CYAN='\033[0;36m' + +if [ "$(id -u)" != "0" ]; then + echo -e "${CYAN}[Bastion]: ${ORANGE}[ERROR] Bastion BOT Installer requires root permissions.${NC}" + hash sudo &>/dev/null || (echo -e "${CYAN}[Bastion]: ${NC} Run this installer with root permissions.\n" && exit 1) + sudo ./run.sh + exit 1 +fi + +if [ -d node_modules ]; then + echo -e "${CYAN}[Bastion]:${NC} Deleting old dependencies..." + rm -r node_modules + echo -e "${CYAN}[Bastion]:${NC} Done." + echo -e "${CYAN}[Bastion]:${NC} Installing new dependencies... This may take a while, please be patient." + npm install &>/dev/null + echo -e "${CYAN}[Bastion]:${NC} Done." + echo -e "${CYAN}[Bastion]:${NC} Ready to boot up and start running." +fi +echo