aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlee <alee14498@gmail.com>2018-04-20 16:58:07 -0400
committerAlee <alee14498@gmail.com>2018-04-20 16:58:07 -0400
commit4648caa22725bbcc6e0f8a25f521b545b4563949 (patch)
tree28ccc8a916ae149bad00be020f4165a96cfc2188
parent986c88ff3d8093495604a3ee1c8cc7746480aa7f (diff)
downloadAleeBot-4648caa22725bbcc6e0f8a25f521b545b4563949.tar.gz
AleeBot-4648caa22725bbcc6e0f8a25f521b545b4563949.tar.bz2
AleeBot-4648caa22725bbcc6e0f8a25f521b545b4563949.zip
Custom prefixes!
-rw-r--r--bot_discord.js18
-rw-r--r--commands/changelog.js2
-rw-r--r--commands/setprefix.js48
-rw-r--r--package-lock.json6
-rw-r--r--storage/prefixes.json1
-rw-r--r--storage/settings.json2
-rw-r--r--update_dep.bat4
7 files changed, 73 insertions, 8 deletions
diff --git a/bot_discord.js b/bot_discord.js
index fd14c49..9252e3d 100644
--- a/bot_discord.js
+++ b/bot_discord.js
@@ -35,7 +35,7 @@ const log = message => {
};
-console.log('AleeBot: Copyright (C) 2018 AleeCorp');
+console.log(`AleeBot ${settings.abVersion}: Copyright (C) 2018 AleeCorp`);
console.log('This program comes with ABSOLUTELY NO WARRANTY; for details type `show w\'.');
console.log ('This is free software, and you are welcome to redistribute it');
console.log ('under certain conditions; type `show c\' for details.\n')
@@ -126,8 +126,20 @@ client.on('guildDelete', guild => {
client.on('message', (msg) => {
if (msg.author.bot) return;
- if (!msg.content.startsWith(settings.prefix)) return;
- const args = msg.content.slice(settings.prefix.length).trim().split(/ +/g);
+
+ let prefixes = JSON.parse(fs.readFileSync("./storage/prefixes.json", "utf8"));
+
+ if(!prefixes[msg.guild.id]){
+ prefixes[msg.guild.id] = {
+ prefixes: settings.prefix
+ };
+ }
+
+ let prefix = prefixes[msg.guild.id].prefixes
+
+
+ if (!msg.content.startsWith(prefix)) return;
+ const args = msg.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift();
let cmd;
diff --git a/commands/changelog.js b/commands/changelog.js
index d719b53..d5d9584 100644
--- a/commands/changelog.js
+++ b/commands/changelog.js
@@ -22,7 +22,7 @@ module.exports.run = async (client, message) => {
const embed = new Discord.RichEmbed()
.setAuthor('AleeBot ' + require('../storage/settings.json').abVersion + ' Changelog', 'https://cdn.discordapp.com/avatars/282547024547545109/6c147a444ae328c38145ef1f74169e38.png?size=2048')
.setDescription('What\'s new in AleeBot '+ require('../storage/settings.json').abVersion +'?')
- .addField('1. Suggest a feature for AleeBot!', 'You can now suggest a feature for AleeBot!')
+ .addField('1. Setting a custom prefix for AleeBot!', 'We\'ve finally did it! You can now set a prefix!')
.setColor('#1fd619');
message.channel.send({embed});
diff --git a/commands/setprefix.js b/commands/setprefix.js
new file mode 100644
index 0000000..876f6e6
--- /dev/null
+++ b/commands/setprefix.js
@@ -0,0 +1,48 @@
+/****************************************
+ *
+ * SetPrefix: Command for AleeBot
+ * Copyright (C) 2018 AleeCorp
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * *************************************/
+module.exports.run = async (client, message, args) => {
+ const fs = require('fs');
+ if(!message.member.hasPermission("ADMINISTRATOR")) return message.reply('Sorry you need admin to set my prefix')
+ if(!args[0] || args[0 == "help"]) return message.reply('Usage: ab:setprefix <prefix>')
+
+ let prefixes = JSON.parse(fs.readFileSync("./storage/prefixes.json", "utf8"));
+
+ prefixes[message.guild.id] = {
+ prefixes: args[0]
+ };
+
+ fs.writeFile("./storage/prefixes.json", JSON.stringify(prefixes), (err) =>{
+ if (err) log(err)
+ })
+
+ message.reply(`AleeBot's Prefix in this guild is now \`${args[0]}\``);
+ };
+
+ exports.conf = {
+ aliases: [],
+ guildOnly: true,
+ };
+ exports.help = {
+ name: 'setprefix',
+ description: 'Sets the guild prefix.',
+ usage: 'setprefix [prefix]',
+ category: '- General Commands',
+ };
+ \ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 5ff0816..82225ce 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -53,9 +53,9 @@
"integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA=="
},
"moment": {
- "version": "2.22.0",
- "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.0.tgz",
- "integrity": "sha512-1muXCh8jb1N/gHRbn9VDUBr0GYb8A/aVcHlII9QSB68a50spqEVLIGN6KVmCOnSvJrUhC0edGgKU5ofnGXdYdg=="
+ "version": "2.22.1",
+ "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.1.tgz",
+ "integrity": "sha512-shJkRTSebXvsVqk56I+lkb2latjBs8I+pc2TzWc545y2iFnSjm7Wg0QMh+ZWcdSLQyGEau5jI8ocnmkyTgr9YQ=="
},
"nan": {
"version": "2.7.0",
diff --git a/storage/prefixes.json b/storage/prefixes.json
new file mode 100644
index 0000000..9e26dfe
--- /dev/null
+++ b/storage/prefixes.json
@@ -0,0 +1 @@
+{} \ No newline at end of file
diff --git a/storage/settings.json b/storage/settings.json
index 2342656..9ab6590 100644
--- a/storage/settings.json
+++ b/storage/settings.json
@@ -1,4 +1,4 @@
{
- "abVersion": "2.8.1",
+ "abVersion": "2.8.2",
"prefix": "ab:"
}
diff --git a/update_dep.bat b/update_dep.bat
new file mode 100644
index 0000000..7b993ec
--- /dev/null
+++ b/update_dep.bat
@@ -0,0 +1,4 @@
+@echo off
+title Installing/Updating Dependencies
+npm install
+exit \ No newline at end of file