merge fixing

This commit is contained in:
nolan 2020-05-22 15:17:11 -04:00
commit c3490572d0
15 changed files with 243 additions and 118 deletions

View File

@ -0,0 +1,86 @@
//modlogs setting
[S_MODLOGS_DESCRIPTION]
Define the channel to which moderation logs are sent. The setting also allows you to exclude types of actions from being logged in the channel.
[S_MODLOGS_CHANNEL404]
{val} does not resolve into a channel.
[S_MODLOGS_CHANNEL_SUCCESS]
Successfully set the modlogs channel to {channel}.
[S_MODLOGS_EXCLUDE404]
Missing arguments.
//mute Setting
[S_MUTE_DESCRIPTION]
Assign or create a muted role and choose mute functionality for your guild.
__Mute Types__
**`0`:** Mutes only add/remove the muted role. *(default)*
**`1`:** Mutes remove all roles except for the muted role.
**`2`:** Mutes remove all roles, does not require a muted role.
[S_MUTE_TYPENAN]
The argument provided is not a number! The available types are: `0`, `1`, or `2`.
View `{prefix}setting mute` for more help.
[S_MUTE_TYPEINVALID]
The argument provided is not a valid type! The available types are: `0`, `1`, or `2`.
View `{prefix}setting mute` for more help.
[S_MUTE_TYPESUCCESS]
Successfully set the **mute type** to `{type}`.
[S_MUTE_TYPESWITCH]
switch({type}) {
case 0:
"Mutes will now *only add/remove* the muted role.";
break;
case 1:
"Mutes will now *remove all roles except for the muted role*, and then add them back once done.";
break;
case 2:
"Mutes will now *remove all roles* and then add them back once done.";
break;
}
[S_MUTE_ROLEMISSINGPERMISSION]
The bot *must have* the `MANAGE_ROLES` permission to create a new mute role.
[S_MUTE_ROLEPROMPT]
Found an existing role named **{name}** `({id})`, would you like to use it and update these roles permissions?
Answering no will create a new role with updated permissions. *(__y__es, __n__o)*
This prompt will time out in __30 seconds__.
[S_MUTE_ROLEPROMPTERROR]
You provided an invalid input, please try again.
[S_MUTE_ROLECREATEERROR]
The bot encountered an issue while creating a role for the guild.
[S_MUTE_ROLEMISSING]
Cannot find a specified role with those arguments.
To create a new role, try `{prefix}setting createmute Muted`
[S_MUTE_ROLESUCCESS]
Successfully {type} the **mute role** to `{role}`.
[S_MUTE_GENERATEDPERMISSIONS]
**Permissions have been applied to all possible channels.**
[S_MUTE_UNGENERATEDPERMISSIONS]
**None of the permissions have been changed.**
[S_MUTEDROLE_MISSINGPERMISSION]
The bot must have the `MANAGE_ROLES` permission to create a new muted role in the guild.
[S_MUTEDROLE_ERRORCREATE]
There was an issue creating the muted role for your guild.
[S_MUTEDROLE_CANNOTFIND]
I cannot find a role name with those arguments. If you would like to create a new one, use the command `{prefix}settings mute create`.
[S_MUTEDROLE_SUCCESS]
Successfully set the muted role to `{role}`.

View File

@ -18,93 +18,7 @@ The guild prefix cannot include spaces.
[S_GUILDPREFIX_RESET]
Successfully reset the guild prefix to `{prefix}`.
//mute Setting
[S_MUTE_DESCRIPTION]
Assign or create a muted role and choose mute functionality for your guild.
__Mute Types__
**`0`:** Mutes only add/remove the muted role. *(default)*
**`1`:** Mutes remove all roles except for the muted role.
**`2`:** Mutes remove all roles, does not require a muted role.
[S_MUTE_TYPENAN]
The argument provided is not a number! The available types are: `0`, `1`, or `2`.
View `{prefix}setting mute` for more help.
[S_MUTE_TYPEINVALID]
The argument provided is not a valid type! The available types are: `0`, `1`, or `2`.
View `{prefix}setting mute` for more help.
[S_MUTE_TYPESUCCESS]
Successfully set the **mute type** to `{type}`.
[S_MUTE_TYPESWITCH]
switch({type}) {
case 0:
"Mutes will now *only add/remove* the muted role.";
break;
case 1:
"Mutes will now *remove all roles except for the muted role*, and then add them back once done.";
break;
case 2:
"Mutes will now *remove all roles* and then add them back once done.";
break;
}
[S_MUTE_ROLEMISSINGPERMISSION]
The bot *must have* the `MANAGE_ROLES` permission to create a new mute role.
[S_MUTE_ROLEPROMPT]
Found an existing role named **{name}** `({id})`, would you like to use it and update these roles permissions?
Answering no will create a new role with updated permissions. *(__y__es, __n__o)*
This prompt will time out in __30 seconds__.
[S_MUTE_ROLEPROMPTERROR]
You provided an invalid input, please try again.
[S_MUTE_ROLECREATEERROR]
The bot encountered an issue while creating a role for the guild.
[S_MUTE_ROLEMISSING]
Cannot find a specified role with those arguments.
To create a new role, try `{prefix}setting createmute Muted`
[S_MUTE_ROLESUCCESS]
Successfully {type} the **mute role** to `{role}`.
[S_MUTE_GENERATEDPERMISSIONS]
**Permissions have been applied to all possible channels.**
[S_MUTE_UNGENERATEDPERMISSIONS]
**None of the permissions have been changed.**
[S_MUTEDROLE_MISSINGPERMISSION]
The bot must have the `MANAGE_ROLES` permission to create a new muted role in the guild.
[S_MUTEDROLE_ERRORCREATE]
There was an issue creating the muted role for your guild.
[S_MUTEDROLE_CANNOTFIND]
I cannot find a role name with those arguments. If you would like to create a new one, use the command `{prefix}settings mute create`.
[S_MUTEDROLE_SUCCESS]
Successfully set the muted role to `{role}`.
//User Settings

View File

@ -42,7 +42,7 @@ class MongoDBProvider extends Provider {
if (!this._initialized) return { error: true, message: 'MongoDB not connected' };
if (!this[request.type]) return { error: true, message: `Invalid request type, got '${request.type}'` };
if (!request.collection && request.type !== 'stats') return { error: true, message: `You must specify a collection to query!` };
if (!request.collection && request.type !== 'stats') return { error: true, message: 'You must specify a collection to query!' };
return this[request.type](request);

View File

@ -141,8 +141,11 @@ class Resolver {
}
async resolveUser(resolveable, strict) {
if (!resolveable) return false;
const result = await this.resolveUsers([ resolveable ], strict);
return result ? result[0] : false;
}
/**
@ -211,6 +214,7 @@ class Resolver {
async resolveMember(resolveable, guild, strict) {
if (!resolveable) return false;
const result = await this.resolveMembers([ resolveable ], guild, strict);
return result ? result[0] : false;
@ -274,6 +278,7 @@ class Resolver {
resolveChannel(resolveable, guild, strict) {
if (!resolveable) return false;
const result = this.resolveChannels([resolveable], guild, strict);
return result ? result[0] : false;
@ -327,6 +332,7 @@ class Resolver {
async resolveRole(resolveable, guild, strict) {
if (!resolveable) return false;
const result = await this.resolveRoles([resolveable], guild, strict);
return result ? result[0] : false;

View File

@ -23,13 +23,13 @@ class Evaluate extends Command {
name: 'log',
type: 'BOOLEAN',
types: ['FLAG'],
description: "Logs the output in the console."
description: 'Logs the output in the console.'
},
{
name: 'hide',
type: 'BOOLEAN',
types: ['FLAG'],
description: "Hides the output from the channel."
description: 'Hides the output from the channel.'
}
],
showUsage: true

View File

@ -31,7 +31,7 @@ class HelpCommand extends Command {
description: message.format('C_HELP_TEMPLATE', {
desc: message.format(result.description),
component: result.name.toUpperCase(),
text: message.format(result.example)
text: result.examples.map(ex => `\`{prefix}${result.name} ${ex}\``).join('\n')
})//,
// fields: [
// {

View File

@ -1,4 +1,4 @@
const { Command } = require('../../../../interfaces/');
const { Command } = require('../../../../interfaces');
const { stripIndents } = require('common-tags');
@ -28,7 +28,11 @@ class SettingsCommand extends Command {
default: true
}
],
showUsage: true
showUsage: true,
examples: [
'prefix !',
'modlogs #channel'
]
});
this.client = client;
@ -134,13 +138,13 @@ class SettingsCommand extends Command {
async _showSetting(message, setting) {
const prefix = message.guild.prefix;
let description = stripIndents`\`${prefix}setting ${setting.name}${setting.usage ? ` ${setting.usage}` : ''}\` ${setting.resolve === 'GUILD' ? ' *(guild-only)*' : '*(user-only)*'}
let description = stripIndents`\`${prefix}settings ${setting.name}${setting.usage ? ` ${setting.usage}` : ''}\` ${setting.resolve === 'GUILD' ? ' *(guild-only)*' : '*(user-only)*'}
${message.format(setting.description)}`;
if(setting.examples.length > 0) {
description += `\n\n**${message.format('GENERAL_EXAMPLES')}**`;
for(let example of setting.examples) {
description += `\n\`${prefix}setting ${example}\``;
description += `\n\`${prefix}settings ${example}\``;
}
}

View File

@ -8,7 +8,7 @@ class UserCommand extends Command {
super(client, {
name: 'user',
module: 'utility',
description: "Display information about user.",
description: 'Display information about user.',
guildOnly: true,
arguments: [
{

View File

@ -1,7 +1,7 @@
const { Inhibitor } = require('../../../interfaces/');
const { stripIndents } = require('common-tags');
class GuildOnly extends Inhibitor {
class Throttle extends Inhibitor {
constructor(client) {
@ -47,4 +47,4 @@ class GuildOnly extends Inhibitor {
}
module.exports = GuildOnly;
module.exports = Throttle;

View File

@ -154,7 +154,7 @@ class CommandHandler extends Observer {
}
async _parseArguments(args = [], passedArguments = [], guild = null) { //Only need guild parameter if using a resolver type in your arguments e.g. channel, user, member, role
async _parseArguments(args = [], passedArguments = [], guild = null, debug = false) { //Only need guild parameter if using a resolver type in your arguments e.g. channel, user, member, role
args = this._getWords(args.join(' ')).map(w=>w[0]);
@ -167,6 +167,10 @@ class CommandHandler extends Observer {
let currentArgument = null;
for(let i=0; i<args.length; i++) {
const word = args[i];
if(debug) {
console.log("parsing word", word)
console.log("parsing word value", currentArgument?.value);
}
if(!word) continue;
const [one,two,...chars] = word.split('');
if(one === '-' && two !== '-') {
@ -233,6 +237,7 @@ class CommandHandler extends Observer {
}
}
const value = match[1] || match[3];
if(debug) console.log("type parsing", currentArgument.name, value)
const error = await this._handleTypeParsing(currentArgument, value, guild);
if(value) {
if(error) {
@ -255,11 +260,12 @@ class CommandHandler extends Observer {
continue;
}
} else {
if(debug) console.log(word);
if(debug) console.log("whattttttttttttttt");
continue;
}
} else {
if(currentArgument) {
if(debug) console.log(word);
const error = await this._handleTypeParsing(currentArgument, word, guild);
if(error) {
if(currentArgument.default !== null) {
@ -371,7 +377,7 @@ class CommandHandler extends Observer {
const { error, value } = await parse(argument, string, guild);
if(!error && value !== undefined) {
if(!error && (value !== undefined || value !== '')) {
argument.infinite
? argument.value.push(value)
: argument.value = value;

View File

@ -0,0 +1,110 @@
const { Setting } = require('../../../../interfaces/');
class Modlogs extends Setting {
constructor(client) {
super(client, {
name: 'moderationLog',
module: 'moderation',
aliases: [
'moderationLogs',
'modLog',
'modLogs'
],
guarded: true,
resolve: 'GUILD',
//custom: true,
examples: [
'modlog #moderation-log',
'modlog reset'
],
arguments: [
{
name: 'exclude',
type: 'STRING',
types: ['VERBAL'],
requiredValue: true,
infinite: true
}
],
default: {
modlogs: {
channel: undefined,
exclude: []
}
}
});
this.client = client;
}
async handle(message, args) {
const { params, parsedArguments } = await this._parseArguments(args, message.guild, true);
console.log(params)
console.log(Object.values(parsedArguments).map(a=>`${a.name} - ${a.value}`));
let setting = message.guild._settings.modlogs || { };
if (parsedArguments.exclude) {
if (!parsedArguments.exclude.value.length) return {
msg: message.format('S_MODLOGS_EXCLUDE404'),
error: true
}
} else {
let [channel] = params;
if (channel === 'reset') {
setting = {};
await message.guild._updateSettings({ [this.index]: setting });
return {
msg: message.format('S_MODLOGS_RESET'),
error: false
};
} else {
channel = message.guild.resolveChannel(channel);
if (!channel) return {
msg: message.format('S_MODLOGS_CHANNEL404', { val: params[0] }),
error: true
};
setting.channel = channel.id;
await message.guild._updateSettings({ [this.index]: setting }); return {
msg: message.format('S_MODLOGS_CHANNEL_SUCCESS', { channel: channel.name }),
error: false
};
}
}
}
data(guild) {
return `**Prefix:** \`${guild.prefix}\``;
}
fields(guild) {
return [
{
name: 'Channel',
value: guild.resolveChannel(guild._settings[this.index]?.channel) || 'N/A',
inline: true
},
{
name: 'Excluded types',
value: guild._settings[this.index]?.exclude.join(', ') || 'N/A',
inline: true
}
];
}
}
module.exports = Modlogs;

View File

@ -30,7 +30,7 @@ class MuteSetting extends Setting {
default: true
}
],
usage: "[test] <what>",
usage: '[test] <what>',
examples: [
'muterole Muted',
'mutetype 1',
@ -165,13 +165,13 @@ class MuteSetting extends Setting {
fields(guild) {
return [
{
name: "》Muted Role",
value: guild._settings[this.index].role ? `<@&${guild._settings[this.index].role}>` : '`N/A`',
name: '》Muted Role',
value: guild._settings[this.index]?.role ? `<@&${guild._settings[this.index].role}>` : '`N/A`',
inline: true
},
{
name: "》Mute Type",
value: `\`${guild._settings[this.index].type}\``,
name: '》Mute Type',
value: `\`${guild._settings[this.index]?.type || 0}\``,
inline: true
}
];

View File

@ -39,9 +39,11 @@ class GuildPrefixSetting extends Setting {
error: true
};
if (prefix === 'reset') prefix = this.default.prefix;
await message.guild._updateSettings({ [this.index]: prefix });
return {
msg: message.format(`S_GUILDPREFIX_SUCCESS`, { prefix }),
msg: message.format('S_GUILDPREFIX_SUCCESS', { prefix }),
error: false
};

View File

@ -37,7 +37,7 @@ class PermissionTypeSetting extends Setting {
await message.guild._updateSettings({ [this.index]: prefix });
return {
msg: message.format(`S_GUILDPREFIX_SUCCESS`, { prefix }),
msg: message.format('S_GUILDPREFIX_SUCCESS', { prefix }),
error: false
};
@ -46,7 +46,7 @@ class PermissionTypeSetting extends Setting {
fields(guild) {
return [
{
name: "》Prefix",
name: '》Prefix',
value: `\`${guild.prefix}\``
}
];

View File

@ -127,34 +127,31 @@ const Guild = Structures.extend('Guild', (Guild) => {
async resolveMember(member, strict) {
const [ result ] = await this.resolveMembers([ member ], strict);
return result;
return await this.client.resolver.resolveMembers(member, this, strict);
}
async resolveChannels(channels, strict = false) {
resolveChannels(channels, strict = false) {
return this.client.resolver.resolveChannels(channels, this, strict);
}
async resolveChannel(channel, strict) {
resolveChannel(channel, strict) {
const [ result ] = await this.resolveMembers([ channel ], strict);
return result;
return this.client.resolver.resolveChannel(channel, this, strict);
}
async resolveRoles(roles, strict = false) {
return this.client.resolver.resolveRoles(roles, this, strict);
return await this.client.resolver.resolveRoles(roles, this, strict);
}
async resolveRole(role, strict) {
const [ result ] = await this.resolveRoles([ role ], strict);
return result;
return await this.client.resolver.resolveRole(role, this, strict);
}