voice logs
This commit is contained in:
parent
53683a66e8
commit
b355cf4b69
98
structure/client/components/settings/moderation/VoiceLogs.js
Normal file
98
structure/client/components/settings/moderation/VoiceLogs.js
Normal file
@ -0,0 +1,98 @@
|
||||
const { Setting } = require('../../../../interfaces/');
|
||||
|
||||
class VoiceLogSettings extends Setting {
|
||||
|
||||
constructor(client) {
|
||||
|
||||
super(client, {
|
||||
name: 'voiceLog',
|
||||
module: 'moderation',
|
||||
aliases: [
|
||||
'vcLog',
|
||||
'vcLogs',
|
||||
'voiceLogs'
|
||||
],
|
||||
usage: '<value>',
|
||||
guarded: true,
|
||||
resolve: 'GUILD',
|
||||
examples: [
|
||||
'voicelog reset',
|
||||
'voicelog on|off',
|
||||
'voicelog #channel'
|
||||
],
|
||||
default: {
|
||||
voiceLog: {
|
||||
channel: null,
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.client = client;
|
||||
|
||||
}
|
||||
|
||||
async handle(message, params) {
|
||||
|
||||
// eslint-disable-next-line init-declarations
|
||||
let index, changes, action;
|
||||
// eslint-disable-next-line prefer-const
|
||||
let [method, ...args] = params;
|
||||
method = method.toLowerCase();
|
||||
|
||||
const setting = message.guild._settings[this.index] || this.default[this.index];
|
||||
const { guild } = message;
|
||||
|
||||
if (this.client.resolver.resolveBoolean(method)) {
|
||||
|
||||
setting.enabled = setting.channel && true;
|
||||
index = 'S_VOICELOG_TOGGLE';
|
||||
changes = message.format('ON_OFF_TOGGLE', { toggle: true }, true);
|
||||
|
||||
} else if (this.client.resolver.resolveBoolean(method) === false) {
|
||||
|
||||
setting.enabled = false;
|
||||
index = 'S_VOICELOG_TOGGLE'
|
||||
changes = message.format('ON_OFF_TOGGLE', { toggle: false }, true);
|
||||
|
||||
} else {
|
||||
|
||||
const channel = guild.resolveChannel(method);
|
||||
if (!channel) return {
|
||||
msg: message.format('ERR_CHANNEL_RESOLVE', { resolveable: method }),
|
||||
error: true
|
||||
};
|
||||
|
||||
index = 'S_VOICELOG_CHANNEL';
|
||||
changes = channel.name;
|
||||
setting.channel = channel.id;
|
||||
setting.enabled = true;
|
||||
|
||||
}
|
||||
|
||||
await message.guild._updateSettings({ [this.index]: setting });
|
||||
return {
|
||||
msg: message.format(index, { changed: changes instanceof Array ? changes?.join(', ') : changes || undefined, action: message.format(action) })
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
async fields(guild) {
|
||||
const setting = guild._settings[this.index];
|
||||
return [
|
||||
{
|
||||
name: '》Enabled',
|
||||
value: setting?.enabled || false,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: '》Channel',
|
||||
value: guild.resolveChannel(setting?.channel) || '`N/A`',
|
||||
inline: true
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = VoiceLogSettings;
|
Loading…
Reference in New Issue
Block a user