revbot.js 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +36 -3
- package/dist/index.d.ts +36 -3
- package/dist/index.js +88 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -864,11 +864,14 @@ var MessageStruct = class extends Base {
|
|
|
864
864
|
/**
|
|
865
865
|
* Retrieves the author of the message.
|
|
866
866
|
*
|
|
867
|
-
* @returns {User | null} The user who authored the message, or `null` if not found.
|
|
867
|
+
* @returns {User | ServerMember | null} The user who authored the message, or `null` if not found.
|
|
868
868
|
*/
|
|
869
869
|
get author() {
|
|
870
|
-
var _a;
|
|
871
|
-
|
|
870
|
+
var _a, _b, _c, _d;
|
|
871
|
+
if (this.inServer()) {
|
|
872
|
+
return (_c = (_b = (_a = this.server) == null ? void 0 : _a.members.cache.get(this.authorId)) != null ? _b : this.client.users.cache.get(this.authorId)) != null ? _c : null;
|
|
873
|
+
}
|
|
874
|
+
return (_d = this.client.users.cache.get(this.authorId)) != null ? _d : null;
|
|
872
875
|
}
|
|
873
876
|
/**
|
|
874
877
|
* Retrieves the channel where the message was sent.
|
|
@@ -2276,6 +2279,58 @@ var ServerMember3 = class extends Base {
|
|
|
2276
2279
|
leave() {
|
|
2277
2280
|
return this.client.servers.delete(this.serverId);
|
|
2278
2281
|
}
|
|
2282
|
+
/**
|
|
2283
|
+
* Gets the effective permissions for this server member based on their roles.
|
|
2284
|
+
*
|
|
2285
|
+
* The permissions are calculated by:
|
|
2286
|
+
* 1. Starting with a base FullPermissions with no permissions
|
|
2287
|
+
* 2. For each role the member has, applying the role's allow permissions
|
|
2288
|
+
* 3. For each role the member has, removing the role's deny permissions
|
|
2289
|
+
*
|
|
2290
|
+
* @returns {FullPermissions} The effective permissions for this member
|
|
2291
|
+
*
|
|
2292
|
+
* @example
|
|
2293
|
+
* ```typescript
|
|
2294
|
+
* const permissions = member.getPermissions();
|
|
2295
|
+
* console.log(permissions.has('MANAGE_MESSAGES')); // true or false
|
|
2296
|
+
* ```
|
|
2297
|
+
*/
|
|
2298
|
+
permissions() {
|
|
2299
|
+
var _a, _b;
|
|
2300
|
+
let permissions = new FullPermissions();
|
|
2301
|
+
for (const role of this.roles) {
|
|
2302
|
+
if ((_a = role.overwrite) == null ? void 0 : _a.allow) {
|
|
2303
|
+
permissions = permissions.add(role.overwrite.allow);
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
for (const role of this.roles) {
|
|
2307
|
+
if ((_b = role.overwrite) == null ? void 0 : _b.deny) {
|
|
2308
|
+
permissions = permissions.remove(role.overwrite.deny);
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
return permissions;
|
|
2312
|
+
}
|
|
2313
|
+
/**
|
|
2314
|
+
* Checks if this server member has a specific permission.
|
|
2315
|
+
*
|
|
2316
|
+
* @param {string | number | FullPermissions} permission - The permission to check for
|
|
2317
|
+
* @returns {boolean} Whether the member has the permission
|
|
2318
|
+
*
|
|
2319
|
+
* @example
|
|
2320
|
+
* ```typescript
|
|
2321
|
+
* if (member.hasPermission('MANAGE_MESSAGES')) {
|
|
2322
|
+
* // Member can manage messages
|
|
2323
|
+
* }
|
|
2324
|
+
* ```
|
|
2325
|
+
*
|
|
2326
|
+
* note this works on the same basis as stoats permissions checking
|
|
2327
|
+
*/
|
|
2328
|
+
hasPermission(permission) {
|
|
2329
|
+
var _a;
|
|
2330
|
+
if (((_a = this.client.servers.cache.get(this.serverId)) == null ? void 0 : _a.ownerId) === this.id)
|
|
2331
|
+
return true;
|
|
2332
|
+
return this.permissions().has(permission);
|
|
2333
|
+
}
|
|
2279
2334
|
// async displayAvatarURL(options?: { size: number }): Promise<string> {
|
|
2280
2335
|
// return await this.user.displayAvatarURL(options);
|
|
2281
2336
|
// }
|
|
@@ -2691,7 +2746,8 @@ var UserManager = class extends BaseManager {
|
|
|
2691
2746
|
});
|
|
2692
2747
|
}
|
|
2693
2748
|
resolve(resolvable) {
|
|
2694
|
-
if (resolvable instanceof MessageStruct)
|
|
2749
|
+
if (resolvable instanceof MessageStruct)
|
|
2750
|
+
return resolvable.author;
|
|
2695
2751
|
return super.resolve(resolvable);
|
|
2696
2752
|
}
|
|
2697
2753
|
/**
|
|
@@ -3228,7 +3284,7 @@ import { EventEmitter } from "node:events";
|
|
|
3228
3284
|
import axios4, { AxiosError } from "axios";
|
|
3229
3285
|
|
|
3230
3286
|
// package.json
|
|
3231
|
-
var version = "0.2.
|
|
3287
|
+
var version = "0.2.3";
|
|
3232
3288
|
|
|
3233
3289
|
// src/rest/restUtils/rateLimitQueue.ts
|
|
3234
3290
|
import axios3 from "axios";
|
|
@@ -3994,13 +4050,33 @@ var ServerRoleUpdate = class extends Event {
|
|
|
3994
4050
|
* @returns {void}
|
|
3995
4051
|
*/
|
|
3996
4052
|
handle(data) {
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4053
|
+
return __async(this, null, function* () {
|
|
4054
|
+
const server = this.client.servers.cache.get(data.id);
|
|
4055
|
+
if (!server) return;
|
|
4056
|
+
let role = server.roles.cache.get(data.role_id);
|
|
4057
|
+
const oldRole = role == null ? void 0 : role._update(data.data, data.clear);
|
|
4058
|
+
if (!oldRole && !role) {
|
|
4059
|
+
yield Promise.all(
|
|
4060
|
+
Object.values(data.data).map((raw) => __async(this, null, function* () {
|
|
4061
|
+
if (raw && typeof raw === "object") {
|
|
4062
|
+
server.roles._add(__spreadProps(__spreadValues({
|
|
4063
|
+
name: "",
|
|
4064
|
+
permissions: {
|
|
4065
|
+
a: 0,
|
|
4066
|
+
d: 0
|
|
4067
|
+
}
|
|
4068
|
+
}, raw), {
|
|
4069
|
+
id: data.role_id
|
|
4070
|
+
}));
|
|
4071
|
+
}
|
|
4072
|
+
}))
|
|
4073
|
+
);
|
|
4074
|
+
role = server.roles.cache.get(data.role_id);
|
|
4075
|
+
}
|
|
4076
|
+
if (role && oldRole && !role.equals(oldRole)) {
|
|
4077
|
+
this.client.emit("roleUpdate" /* ROLE_UPDATE */, oldRole, role);
|
|
4078
|
+
}
|
|
4079
|
+
});
|
|
4004
4080
|
}
|
|
4005
4081
|
};
|
|
4006
4082
|
|