110 lines
2.9 KiB
JavaScript
110 lines
2.9 KiB
JavaScript
|
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;
|