Initial commit
This commit is contained in:
56
src/structures/StoreChannel.js
Normal file
56
src/structures/StoreChannel.js
Normal file
@@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
|
||||
const GuildChannel = require('./GuildChannel');
|
||||
|
||||
/**
|
||||
* Represents a guild store channel on Discord.
|
||||
* <warn>Store channels are deprecated and will be removed from Discord in March 2022. 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;
|
||||
Reference in New Issue
Block a user