Definitely working structures

This commit is contained in:
Neko Life 2021-05-24 17:26:11 +00:00
parent 4140f5c49b
commit b7b5d0dc5d

View file

@ -15,27 +15,30 @@ Structures.extend("Guild", g => {
} }
/** /**
* Get user infractions * Get user infractions
* @param {User} get - User object * @param {String} get - User ID
* @returns {Array<Object>} Infractions object * @returns {Promise<Object[]>} Infractions object
*/ */
async getInfractions(get) { async getInfractions(get) {
let found; try {
const r = await database.collection("Guild").findOne({ document: this.id });
this.infractions = r?.moderation?.infractions;
let found = [];
if (this.infractions.length > 0) { if (this.infractions.length > 0) {
found = []; for (const inf of this.infractions) {
this.infractions.map(r => { let added = false;
if (r) { for (const user of inf.by) {
for (const inf of r) { if (user.id === get) {
if (inf?.by) {
if (inf.by.includes(get)) {
found.push(inf); found.push(inf);
break;
} }
} }
} }
} if (found.length > 0) {
});
}
return found; return found;
} }
}
} catch (e) { }
}
async setDefaultEmbed(set) { async setDefaultEmbed(set) {
await database.collection("Guild").updateOne({document: this.id}, {$set:{"settings.defaultEmbed": set}}, {upsert: true}).catch(e => {throw e}); await database.collection("Guild").updateOne({document: this.id}, {$set:{"settings.defaultEmbed": set}}, {upsert: true}).catch(e => {throw e});
this.defaultEmbed = set; this.defaultEmbed = set;