seyfert
Version:
The most advanced framework for discord bots
47 lines (46 loc) • 1.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GuildRole = void 0;
const common_1 = require("../common");
const DiscordBase_1 = require("./extra/DiscordBase");
const Permissions_1 = require("./extra/Permissions");
class GuildRole extends DiscordBase_1.DiscordBase {
guildId;
permissions;
constructor(client, data, guildId) {
super(client, data);
this.guildId = guildId;
this.permissions = new Permissions_1.PermissionsBitField(BigInt(data.permissions));
}
guild(mode = 'flow') {
switch (mode) {
case 'cache':
return (this.client.cache.guilds?.get(this.guildId) ||
(this.client.cache.adapter.isAsync ? Promise.resolve() : undefined));
default:
return this.client.guilds.fetch(this.guildId, mode === 'rest');
}
}
fetch(force = false) {
return this.client.roles.fetch(this.guildId, this.id, force);
}
edit(body) {
return this.client.roles.edit(this.guildId, this.id, body);
}
delete(reason) {
return this.client.roles.delete(this.guildId, this.id, reason);
}
toString() {
return common_1.Formatter.roleMention(this.id);
}
static methods(ctx) {
return {
create: (body) => ctx.client.roles.create(ctx.guildId, body),
list: (force = false) => ctx.client.roles.list(ctx.guildId, force),
edit: (roleId, body, reason) => ctx.client.roles.edit(ctx.guildId, roleId, body, reason),
delete: (roleId, reason) => ctx.client.roles.delete(ctx.guildId, roleId, reason),
editPositions: (body) => ctx.client.roles.editPositions(ctx.guildId, body),
};
}
}
exports.GuildRole = GuildRole;