UNPKG

seyfert

Version:

The most advanced framework for discord bots

45 lines (44 loc) 1.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GuildBan = void 0; const common_1 = require("../common"); const DiscordBase_1 = require("./extra/DiscordBase"); class GuildBan extends DiscordBase_1.DiscordBase { guildId; constructor(client, data, guildId) { const id = 'user' in data ? data.user.id : data.id; super(client, { ...data, id }); this.guildId = guildId; } create(body, reason) { return this.client.bans.create(this.guildId, this.id, body, reason); } remove(reason) { return this.client.bans.remove(this.guildId, this.id, reason); } 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.bans.fetch(this.guildId, this.id, force); } toString() { return common_1.Formatter.userMention(this.id); } static methods({ client, guildId }) { return { fetch: (userId, force = false) => client.bans.fetch(guildId, userId, force), list: (query, force = false) => client.bans.list(guildId, query, force), create: (memberId, body, reason) => client.bans.create(guildId, memberId, body, reason), remove: (memberId, reason) => client.bans.remove(guildId, memberId, reason), bulkCreate: (body, reason) => client.bans.bulkCreate(guildId, body, reason), }; } } exports.GuildBan = GuildBan;