mirror of
https://github.com/danbulant/Shasha
synced 2026-06-19 14:21:37 +00:00
Definitely working structures
This commit is contained in:
parent
4140f5c49b
commit
b7b5d0dc5d
1 changed files with 18 additions and 15 deletions
|
|
@ -15,26 +15,29 @@ Structures.extend("Guild", g => {
|
|||
}
|
||||
/**
|
||||
* Get user infractions
|
||||
* @param {User} get - User object
|
||||
* @returns {Array<Object>} Infractions object
|
||||
* @param {String} get - User ID
|
||||
* @returns {Promise<Object[]>} Infractions object
|
||||
*/
|
||||
async getInfractions(get) {
|
||||
let found;
|
||||
if (this.infractions.length > 0) {
|
||||
found = [];
|
||||
this.infractions.map(r => {
|
||||
if (r) {
|
||||
for (const inf of r) {
|
||||
if (inf?.by) {
|
||||
if (inf.by.includes(get)) {
|
||||
found.push(inf);
|
||||
}
|
||||
try {
|
||||
const r = await database.collection("Guild").findOne({ document: this.id });
|
||||
this.infractions = r?.moderation?.infractions;
|
||||
let found = [];
|
||||
if (this.infractions.length > 0) {
|
||||
for (const inf of this.infractions) {
|
||||
let added = false;
|
||||
for (const user of inf.by) {
|
||||
if (user.id === get) {
|
||||
found.push(inf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return found;
|
||||
if (found.length > 0) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
} catch (e) { }
|
||||
}
|
||||
async setDefaultEmbed(set) {
|
||||
await database.collection("Guild").updateOne({document: this.id}, {$set:{"settings.defaultEmbed": set}}, {upsert: true}).catch(e => {throw e});
|
||||
|
|
|
|||
Loading…
Reference in a new issue