UNPKG

guilded.ts

Version:

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

66 lines 2.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Group = void 0; const Base_1 = require("./Base"); const GroupMemberManager_1 = require("../managers/group/GroupMemberManager"); /** * Represents a group on Guilded. * @example new Group(client, rawGroup); */ class Group extends Base_1.Base { raw; /** The manager of members that belong to the group. */ members; /** * @param client The client the group belongs to. * @param raw The raw data of the group. * @param cache Whether to cache the group. */ constructor(client, raw, cache = client.options.cacheGroups ?? true) { super(client, raw.id); this.raw = raw; this.members = new GroupMemberManager_1.GroupMemberManager(this); if (cache) client.groups.cache.set(this.id, this); } /** Whether the group is cached. */ get isCached() { return this.client.groups.cache.has(this.id); } /** * Fetch the group. * @param options The options to fetch the group with. * @returns The fetched group. * @example group.fetch(); */ fetch(options) { return this.client.groups.fetch(this, options); } /** * Add a member to the group. * @param member The member to add. * @example group.addMember(member); */ addMember(member) { return this.members.add(member); } /** * Remove a member from the group. * @param member The member to remove. * @example group.removeMember(member); */ removeMember(member) { return this.members.remove(member); } /** * Create a channel in the group. * @param payload The payload of the channel. * @returns The created channel. * @example group.createChannel({ name: 'Chat', type: 'chat' }); */ createChannel(payload) { return this.client.channels.create({ groupId: this.id, ...payload }); } } exports.Group = Group; //# sourceMappingURL=Group.js.map