UNPKG

guilded.ts

Version:

A powerful NPM module that allows you to easily interact with the Guilded API.

76 lines 2.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ServerBan = void 0; const Base_1 = require("../Base"); const User_1 = require("../User"); /** * Represents a server ban on Guilded. * @example new ServerBan(server, rawBan); */ class ServerBan extends Base_1.Base { server; raw; /** The user the ban belongs to. */ user; /** The reason of the ban. */ reason; /** The ID of the user that created the ban. */ createdBy; /** The date the ban was created. */ createdAt; /** * @param server The server the ban belongs to. * @param raw The raw data of the server ban. * @param cache Whether to cache the server ban. */ constructor(server, raw, cache = server.client.options.cacheServerBans ?? true) { super(server.client, raw.user.id); this.server = server; this.raw = raw; this.user = new User_1.User(server.client, raw.user); this.reason = raw.reason; this.createdBy = raw.createdBy; this.createdAt = new Date(raw.createdAt); if (cache) server.bans.cache.set(this.id, this); } /** Whether the server ban is cached. */ get isCached() { return this.server.bans.cache.has(this.id); } /** The user that created the server ban. */ get author() { return this.client.users.cache.get(this.createdBy); } /** The timestamp the ban was created. */ get createdTimestamp() { return this.createdAt.getTime(); } /** * Fetch the server ban. * @param options The options to fetch the server ban with. * @returns The fetched server ban. * @example ban.fetch(); */ fetch(options) { return this.server.bans.fetch(this, options); } /** * Fetch the server member that created the ban. * @param options The options to fetch the server member with. * @returns The fetched server member. * @example ban.fetchAuthor(); */ fetchAuthor(options) { return this.server.members.fetch(this.createdBy, options); } /** * Remove the server ban from the server. * @example ban.remove(); */ remove() { return this.server.bans.remove(this); } } exports.ServerBan = ServerBan; //# sourceMappingURL=ServerBan.js.map