2020-05-22 22:13:47 +02:00
|
|
|
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) {
|
|
|
|
|
2020-05-23 10:11:14 +02:00
|
|
|
console.log('\n==PARSING FROM MODLOGS SETTING==')
|
2020-05-22 22:13:47 +02:00
|
|
|
const { params, parsedArguments } = await this._parseArguments(args, message.guild, true);
|
|
|
|
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;
|