galactic-bot/structure/client/components/settings/logging/DmInfraction.js

102 lines
2.9 KiB
JavaScript
Raw Normal View History

2021-05-08 19:42:30 +02:00
const { Setting } = require('../../../../interfaces');
2020-06-04 19:59:09 +02:00
2020-08-31 18:47:20 +02:00
const Constants = {
Infractions: [
'NOTE',
'WARN',
'MUTE',
'UNMUTE',
'KICK',
'SOFTBAN',
'BAN',
'UNBAN',
'VCMUTE',
'VCUNMUTE',
'VCKICK',
'VCBAN',
'VCUNBAN',
'REMOVEROLE',
'ADDROLE',
'NICKNAME'
]
};
2020-06-04 19:59:09 +02:00
class DmInfractionSetting extends Setting {
constructor(client) {
super(client, {
name: 'dmInfraction',
2021-05-08 19:42:30 +02:00
module: 'logging',
2020-06-04 19:59:09 +02:00
aliases: [
'directMessageInfraction',
'privateLog',
'dmLog'// idk...
],
2020-08-31 18:47:20 +02:00
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/"
],
2020-06-04 19:59:09 +02:00
default: {
dmInfraction: {
enabled: false,
2020-08-31 18:47:20 +02:00
infractions: ['WARN', 'MUTE', 'UNMUTE', 'KICK', 'SOFTBAN', 'BAN', 'UNBAN', 'VCMUTE', 'VCUNMUTE', 'VCKICK', 'VCBAN', 'VCUNBAN'],
messages: {
2020-07-20 00:42:21 +02:00
default: "You were **{infraction}** {from|on} the server `{server}`, your infraction details are below."
2020-06-04 19:59:09 +02:00
//BAN: etc
}
}
},
archivable: false
2020-06-04 19:59:09 +02:00
});
}
async handle(message, args) {
2020-08-31 18:47:20 +02:00
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', { bool: boolean }, { code: true }) }),
2020-08-31 18:47:20 +02:00
error: false
};
}
// const result = this.client.resolver.list(
// setting.infractions,
// Constants.Infractions,
// args,
// this.client.resolver.resolveInfractions.bind(this.client.resolver)
// );
2020-08-31 18:47:20 +02:00
2020-08-31 16:50:20 +02:00
// if(result) {
// const method =
// }
2020-06-04 19:59:09 +02:00
}
async fields(guild) {
const setting = guild._settings[this.index];
2020-08-31 18:47:20 +02:00
return [
{
name: '》 Status',
value: guild.format('SETTING_STATUS', { bool: Boolean(setting?.enabled) }, true),
inline: true
2020-08-31 18:47:20 +02:00
}
];
2020-06-04 19:59:09 +02:00
}
}
module.exports = DmInfractionSetting;