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,26 +15,29 @@ 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 {
if (this.infractions.length > 0) { const r = await database.collection("Guild").findOne({ document: this.id });
found = []; this.infractions = r?.moderation?.infractions;
this.infractions.map(r => { let found = [];
if (r) { if (this.infractions.length > 0) {
for (const inf of r) { for (const inf of this.infractions) {
if (inf?.by) { let added = false;
if (inf.by.includes(get)) { for (const user of inf.by) {
found.push(inf); if (user.id === get) {
} 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});