Servers now have server spesific prefixes
This commit is contained in:
@@ -25,6 +25,7 @@ function addCommand(name, command, alt, usage, desc, requrePerms, functionRefere
|
||||
}
|
||||
|
||||
/*command name, command, alt, usage, description, require permission, reference*/
|
||||
|
||||
module.exports.loadCommands = function() {
|
||||
//general commands
|
||||
addCommand('Help', 'help', undefined, 'help [command] or [help]', 'Returns a usage chart for the command requested, or returns a link to a command list', false, Commands.help);
|
||||
@@ -49,6 +50,6 @@ module.exports.loadCommands = function() {
|
||||
//admin commands
|
||||
addCommand('Shutdown', 'stop', undefined, 'stop', 'Shutsdown JefferyBot', true, AdminCommands.stop);
|
||||
addCommand('Reload', 'reload', undefined, 'reload', 'Reloads the server config and the misc config', false, AdminCommands.reload);
|
||||
addCommand('Set Prefix', 'setprefix', undefined, 'setprefix [new prefix]', 'Changes Jeffery\'s prefix to the new prefix', true, AdminCommands.setprefix);
|
||||
addCommand('Set Prefix', 'setprefix', undefined, 'setprefix [new prefix]', 'Changes Jeffery\'s prefix in the server it was issued in to the new prefix', true, AdminCommands.setprefix);
|
||||
addCommand('Set Game', 'setgame', undefined, 'setgame [new game]', 'Changes Jeffery\'s game to the new game', true, AdminCommands.setgame);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@ const Helper = require('../helper.js');
|
||||
|
||||
/*message object, messaage full, message args, discord client*/
|
||||
|
||||
module.exports.addadminrole = function(message, msg, args, discordclient) {
|
||||
|
||||
}
|
||||
|
||||
module.exports.stop = async function(message, msg, args, discordclient) {
|
||||
message.channel.send(':white_check_mark: \`Disconnected...\`');
|
||||
Logger.failed('Disconnected');
|
||||
@@ -15,14 +19,23 @@ module.exports.stop = async function(message, msg, args, discordclient) {
|
||||
|
||||
module.exports.reload = async function(message, msg, args, discordclient) {
|
||||
try {
|
||||
|
||||
Config.loadFromFile();
|
||||
message.channel.send(':white_check_mark: \`Configuration reloaded...\`');
|
||||
} catch (e) {
|
||||
|
||||
message.channel.send(`:no_entry_sign: \`Could not load the config: ${e.message}\``);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.setprefix = async function(message, msg, args, discordclient) {
|
||||
|
||||
if (args[1]) {
|
||||
var servers = Config.getservers()
|
||||
servers[message.guild.id].prefix = args[1]
|
||||
Config.setservers(servers);
|
||||
Config.writeToFile();
|
||||
message.channel.send(`:white_check_mark: \`The prefix for ${message.guild.name} is now ${args[1]} \``);
|
||||
} else {
|
||||
message.channel.send(':no_entry_sign: \`No new prefix specified\`')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.setgame = async function(message, msg, args, discordclient) {
|
||||
|
||||
0
commands/convertcommands.js
Normal file
0
commands/convertcommands.js
Normal file
@@ -226,8 +226,8 @@ module.exports.vote = async function(message, msg, args, discordclient) {
|
||||
}
|
||||
|
||||
async function startPoll(messageObj, args) {
|
||||
var parsedOptions = await parseOptions(args);
|
||||
var parsedVotes = await getVotes(parsedOptions)
|
||||
var parsedOptions =args.slice(2).join(" ").match(/(\\.|[^/])+/g)
|
||||
var parsedVotes = await getStartingVotes(parsedOptions)
|
||||
polls[messageObj.guild.id] = {
|
||||
options: parsedOptions,
|
||||
votes: parsedVotes,
|
||||
@@ -235,11 +235,7 @@ async function startPoll(messageObj, args) {
|
||||
}
|
||||
}
|
||||
|
||||
async function parseOptions(args) {
|
||||
return args.slice(2).join(" ").match(/(\\.|[^/])+/g)
|
||||
}
|
||||
|
||||
async function getVotes(options) {
|
||||
async function getStartingVotes(options) {
|
||||
var votes = [];
|
||||
for (i in options) {
|
||||
votes.push('0');
|
||||
|
||||
@@ -23,6 +23,7 @@ module.exports.addServer = function(guild) {
|
||||
servers[guild.id] = {
|
||||
name: guild.name,
|
||||
rules: ["Oh yeah, arrays start at 0"],
|
||||
prefix: '+',
|
||||
adminroles: []
|
||||
}
|
||||
}
|
||||
@@ -31,13 +32,13 @@ module.exports.loadDefaults = function() {
|
||||
config = {
|
||||
Token: 'DISCORD_TOKEN',
|
||||
NowPlaying: 'RealLife.exe',
|
||||
Prefix: '+',
|
||||
Version: '2.0.1',
|
||||
};
|
||||
|
||||
servers['SERVER ID'] = {
|
||||
name: 'SERVER NAME',
|
||||
rules: ['RULE 0', 'RULE 1'],
|
||||
prefix: '+',
|
||||
adminroles: ['123456789101112', '123456789101112']
|
||||
};
|
||||
}
|
||||
|
||||
10
main.js
10
main.js
@@ -86,10 +86,14 @@ client.on('ready', () => {
|
||||
/*on message event*/
|
||||
client.on('message', async (message) => {
|
||||
/*if it starts with prefix loaded from config*/
|
||||
if (message.content.startsWith(Config.getconfig().Prefix)) {
|
||||
if (message.content.startsWith(Config.getservers()[message.guild.id].prefix)) {
|
||||
if (message.content.startsWith(';-;') || message.content.startsWith(';_;')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.logMSG(message);
|
||||
var msg = message.content.toLowerCase().substring(Config.getconfig().Prefix.length);
|
||||
var args = message.content.substring(Config.getconfig().Prefix.length).split(' ');
|
||||
var msg = message.content.toLowerCase().substring(Config.getservers()[message.guild.id].prefix.length);
|
||||
var args = message.content.substring(Config.getservers()[message.guild.id].prefix.length).split(' ');
|
||||
args[0] = args[0].toLowerCase();
|
||||
|
||||
/*command manager checks if command exists*/
|
||||
|
||||
Reference in New Issue
Block a user