mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-23 00:03:05 +00:00
✨ AuditLog
This commit is contained in:
1 parent
ce01628650
commit
514afaca69
23 files changed
+136
-58
No files matched your search
@@ -137,7 +137,7 @@ export class BitField {
|
||||
const resolve = this.constructor?.resolve || this.resolve;
|
||||
return bit.map((p) => resolve(p)).reduce((prev, p) => BigInt(prev) | BigInt(p), 0n);
|
||||
}
|
||||
if (typeof bit === "string" && typeof FLAGS[bit] !== "undefined") return this.FLAGS[bit];
|
||||
if (typeof bit === "string" && typeof FLAGS[bit] !== "undefined") return FLAGS[bit];
|
||||
throw new RangeError("BITFIELD_INVALID: " + bit);
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class LongSchema extends mongoose.SchemaType {
|
||||
cast(val: any, scope?: any, init?: any, type?: string) {
|
||||
if (null === val) return val;
|
||||
if ("" === val) return null;
|
||||
if (typeof val === "bigint" && type === "query") {
|
||||
if (typeof val === "bigint") {
|
||||
return mongoose.mongo.Long.fromString(val.toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ChannelDocument, ChannelModel } from "../models/Channel";
|
||||
import { ChannelPermissionOverwrite } from "../models/Channel";
|
||||
import { Role, RoleModel } from "../models/Role";
|
||||
import { BitField } from "./BitField";
|
||||
import { GuildDocument } from "../models/Guild";
|
||||
import { GuildDocument, GuildModel } from "../models/Guild";
|
||||
|
||||
export type PermissionResolvable = bigint | number | Permissions | PermissionResolvable[] | PermissionString;
|
||||
|
||||
@@ -151,6 +151,10 @@ export async function getPermission(
|
||||
) {
|
||||
var { channel, member } = cache || {};
|
||||
|
||||
const guild = await GuildModel.findOne({ id: guild_id }, { owner_id: true }).exec();
|
||||
if (!guild) throw new Error("Guild not found");
|
||||
if (guild.owner_id === user_id) return new Permissions(Permissions.FLAGS.ADMINISTRATOR);
|
||||
|
||||
member = await MemberModel.findOne({ guild_id, id: user_id }, "roles").exec();
|
||||
if (!member) throw new Error("Member not found");
|
||||
|
||||
|
||||
Reference in new issue
Block a user