galactic-bot/structure/client/components/settings/logging/DmInfraction.js
2021-05-08 20:42:30 +03:00

100 lines
2.7 KiB
JavaScript

const { Setting } = require('../../../../interfaces');
const Constants = {
Infractions: [
'NOTE',
'WARN',
'MUTE',
'UNMUTE',
'KICK',
'SOFTBAN',
'BAN',
'UNBAN',
'VCMUTE',
'VCUNMUTE',
'VCKICK',
'VCBAN',
'VCUNBAN',
'REMOVEROLE',
'ADDROLE',
'NICKNAME'
]
};
class DmInfractionSetting extends Setting {
constructor(client) {
super(client, {
name: 'dmInfraction',
module: 'logging',
aliases: [
'directMessageInfraction',
'privateLog',
'dmLog'// idk...
],
usage: "<boolean|method> <value>",
examples: [
"dmInfraction off",
"dmInfraction - warning mute",
"dmInfraction default You have been {infraction-past} in the server {servername}.",
"dmInfraction ban You have been banned! If you would like to appeal this ban, please visit this link: https://google.com/"
],
default: {
dmInfraction: {
enabled: true,
infractions: ['WARN', 'MUTE', 'UNMUTE', 'KICK', 'SOFTBAN', 'BAN', 'UNBAN', 'VCMUTE', 'VCUNMUTE', 'VCKICK', 'VCBAN', 'VCUNBAN'],
messages: {
default: "You were **{infraction}** {from|on} the server `{server}`, your infraction details are below."
//BAN: etc
}
}
},
archivable: false
});
}
async handle(message, args) {
const setting = message.guild._settings[this.index];
const boolean = this.client.resolver.resolveBoolean(args.join(' '));
if(boolean !== null) {
await message.guild._updateSettings({
[this.index]: {
...setting,
enabled: boolean
}
});
return {
msg: message.format('S_DMINFRACTION_TOGGLESUCCESS', { boolean: message.format('SETTING_ENABLEDISABLE', boolean) }),
error: false
};
}
const result = this.client.resolver.list(
setting.infractions,
Constants.Infractions,
args,
this.client.resolver.resolveInfractions.bind(this.client.resolver)
);
// if(result) {
// const method =
// }
}
async fields(guild) {
const setting = guild._settings[this.index];
return [
{
}
];
}
}
module.exports = DmInfractionSetting;