57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
const GuildChannel = require('./GuildChannel');
|
|
|
|
/**
|
|
* Represents a guild store channel on Discord.
|
|
* <warn>Store channels have been removed from Discord. See
|
|
* [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479)
|
|
* for more information.</warn>
|
|
* @extends {GuildChannel}
|
|
*/
|
|
class StoreChannel extends GuildChannel {
|
|
constructor(guild, data, client) {
|
|
super(guild, data, client);
|
|
|
|
/**
|
|
* If the guild considers this channel NSFW
|
|
* @type {boolean}
|
|
*/
|
|
this.nsfw = Boolean(data.nsfw);
|
|
}
|
|
|
|
_patch(data) {
|
|
super._patch(data);
|
|
|
|
if ('nsfw' in data) {
|
|
this.nsfw = Boolean(data.nsfw);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Creates an invite to this guild channel.
|
|
* @param {CreateInviteOptions} [options={}] The options for creating the invite
|
|
* @returns {Promise<Invite>}
|
|
* @example
|
|
* // Create an invite to a channel
|
|
* channel.createInvite()
|
|
* .then(invite => console.log(`Created an invite with a code of ${invite.code}`))
|
|
* .catch(console.error);
|
|
*/
|
|
createInvite(options) {
|
|
return this.guild.invites.create(this.id, options);
|
|
}
|
|
|
|
/**
|
|
* Fetches a collection of invites to this guild channel.
|
|
* Resolves with a collection mapping invites by their codes.
|
|
* @param {boolean} [cache=true] Whether or not to cache the fetched invites
|
|
* @returns {Promise<Collection<string, Invite>>}
|
|
*/
|
|
fetchInvites(cache = true) {
|
|
return this.guild.invites.fetch({ channelId: this.id, cache });
|
|
}
|
|
}
|
|
|
|
module.exports = StoreChannel;
|