From 40a9b92c67f668b0c9d3a6d5021c414ac747e07e Mon Sep 17 00:00:00 2001 From: noolaan Date: Fri, 17 Apr 2020 01:03:53 -0600 Subject: [PATCH] start on moderation infractions and localization stuff --- language/LocaleLoader.js | 0 structure/moderation/infractions/Warning.js | 34 ++++++++++ structure/moderation/infractions/index.js | 3 + structure/moderation/interfaces/Infraction.js | 63 +++++++++++++++++++ structure/moderation/interfaces/index.js | 3 + 5 files changed, 103 insertions(+) create mode 100644 language/LocaleLoader.js create mode 100644 structure/moderation/infractions/Warning.js create mode 100644 structure/moderation/infractions/index.js create mode 100644 structure/moderation/interfaces/Infraction.js create mode 100644 structure/moderation/interfaces/index.js diff --git a/language/LocaleLoader.js b/language/LocaleLoader.js new file mode 100644 index 0000000..e69de29 diff --git a/structure/moderation/infractions/Warning.js b/structure/moderation/infractions/Warning.js new file mode 100644 index 0000000..31dc679 --- /dev/null +++ b/structure/moderation/infractions/Warning.js @@ -0,0 +1,34 @@ +const { Infraction } = require('../interfaces/'); + +class Warning extends Infraction { + + constructor(client, opts = {}) { + + super(client, { + type: 'WARN', + targetType: 'user', + executor: opts.executor.user, + target: opts.target.user, + reason: opts.reason || 'N/A', + guild: opts.guild, + channel: opts.channel, + color: 0xe8d54e, + dictionary: { + past: 'warned', + present: 'warn' + } + }); + + this.client = client; + + this.member = opts.target; + + } + + async handle() { + //Handle anything guild-related. + } + +} + +module.exports = Warning; \ No newline at end of file diff --git a/structure/moderation/infractions/index.js b/structure/moderation/infractions/index.js new file mode 100644 index 0000000..dcc6056 --- /dev/null +++ b/structure/moderation/infractions/index.js @@ -0,0 +1,3 @@ +module.exports = { + Warning: require('./Warning.js') +}; \ No newline at end of file diff --git a/structure/moderation/interfaces/Infraction.js b/structure/moderation/interfaces/Infraction.js new file mode 100644 index 0000000..0283fc1 --- /dev/null +++ b/structure/moderation/interfaces/Infraction.js @@ -0,0 +1,63 @@ +const { stripIndents } = require('common-tags'); + +class Infraction { + + constructor(client, opts = {}) { + + this.client = client; + + this.target = opts.target; //User or channel being targeted. + this.targetType = opts.targetType; // 'user' or 'channek'. + this.executor = opts.executor; //Whoever executed the command. + + this.guild = opts.guild; + this.channel = opts.channel; + + this.case = null; + this.type = opts.type; //What type of infraction (mute, kick, etc.) + + this.timestamp = new Date().getTime(); + this.duration = opts.duration || null; //How long the event will last. Must be in milliseconds. + this.expiration = opts.duration ? opts.duration + this.timestamp : null; //When the event will expire + this.reason = opts.reason; + + this.color = opts.color; //Infraction-defined hexadecimal value to dictate what color the embed is. + this.dictionary = opts.dictionary || {}; // { past: 'banned', present: 'ban' } Infraction-defined object for the correct spellings. + + this._resolved = false; + + } + + async resolve(opts) { + + + + } + + _json() { + return { + id: `${this.guild.id}:${this.case}`, + guild: this.guild.id, + channel: this.channel ? this.channel.id : null, + message: this.message ? this.message.id : null, + executor: this.executor.id, + target: this.target.id, + targetType: this.targetType, + type: this.type, + case: this.case, + duration: this.duration, + expiration: this.expiration, + reason: this.reason, + timestamp: this.timestamp, + } + } + + get targetName() { + return this.targetType === 'user' + ? this.target.tag + : `#${this.target.name}` + } + +} + +module.exports = Infraction; \ No newline at end of file diff --git a/structure/moderation/interfaces/index.js b/structure/moderation/interfaces/index.js new file mode 100644 index 0000000..25c74bf --- /dev/null +++ b/structure/moderation/interfaces/index.js @@ -0,0 +1,3 @@ +module.exports = { + Infraction: require('./Infraction.js') +}; \ No newline at end of file