GuildChannel class

The GuildChannel class extends the Zyno Bot Addons BaseChannel class.

const guildChannel = new GuildChannel(data: GuildChannel, addon: Addon, guild: Guild);

constructor

The GuildChannel class provides three required arguments. The first is a Discord.js channel which is an instance of the GuildChannel class. The second argument is the addon where to create the channel for and has to be an instance of the Addon class. The third argument is the guild where the channel is located in and is an instance of the Guild class.

Properties

id

The id of the channel and is a Twitter snowflake.

name

The name of the channel.

guild

The guild where the channel is located in and is an instance of the Guild class.

guildId

The id of the guild where the channel is located in.

manageable

A boolean which defines whether the bot is able to make changes to the channel or not.

position

A number which defines the position compared to the other channels in the same category (CategoryChannel class) where 0 is the highest position.

deletable

A boolean which defines whether the bot can delete the channel or not.

parent

The CategoryChannel class where the channel is placed in, if the channel is a child of a category channel. If not, this will result in null.

parentId

The id of the category channel where the channel is placed in, if the channel is a child of a category channel. If not, this will result in null.

permissionsLocked

A boolean which defines whether the permissions in the channel are synced with the parent (the category channel where the channel is placed in) or not.

slowMode

The time in miliseconds of the slow mode in the channel. If there isn't set a slow mode, this will result in 0.

nsfw

A boolean which defines whether the channel is a nsfw channel or not.

permissions

A save with the permissions for the members or roles in this channel where the key is the id of the member or role and the value the Permissions class which defines the permissions of the member or role.

type

A string which provides the type of the channel. In the table below is mentioned which types are available:

created

An instance of the default Date class which defines the time when the channel was created.

createdTimestamp

A number which represents the timestamp of when the channel was created.

string

Returns the channel mention as a string.

url

The url of the channel.

viewable

A boolean which defines whether the bot is able to view the channel or not.

Functions

isTextChannel

baseChannel.isTextChannel() : boolean;

Returns a boolean which defines whether the channel is a text channel or not (GuildText or GuildAnnouncement).

isVoiceChannel

baseChannel.isVoiceChannel() : boolean;

Returns a boolean which defines whether the channel is a voice channel or not (GuildVoice).

isVoiceStage

baseChannel.isVoiceStage() : boolean;

Returns a boolean which defines whether the channel is a voice stage channel or not (GuildVoiceStage)

isDM

baseChannel.isDM() : boolean;

Returns a boolean which defines whether the channel is a DM channel or not (DM).

isThread

baseChannel.isThread() : boolean;

Returns a boolean which defines whether the channel is a thread channel or no t(PublicThread, PrivateThread, AnnouncementThread).

isTicket

baseChannel.isTicket() : boolean;

Returns a boolean which defines whether the channel is an open ticket of a user or not.

getTicketOwner

baseChannel.getTicketOwner() : Member | undefined;

Returns a Member class of the member who opened the ticket. If the channel is not a ticket, the function will return undefined.

getTicketInfo

baseChannel.getTicketInfo() : object | undefined;

Returns an object with information of the open ticket. If the channel is not a ticket, the function will return undefined.

{
    channelId: string;
    claimed?: boolean; // Works for tickets created since Zyno Bot version 1.5.0
    category?: string; // Works for tickets created since Zyno Bot version 1.5.0
    owner?: Member; // Almost certainly defined
    closed: boolean;
}

setNSFW

guildChannel.setNSFW(nsfw?: boolean, reason?: string) : Promise<GuildChannel>;

Changes the nsfw status of the channel.

delete

guildChannel.delete() : Promise<void>;

Deletes the channel. The function returns a Promise which will return a void once it's fulfilled.

setName

guildChannel.setName(name: string, reason?: string) : Promise<GuildChannel>;

Changes the name of the channel. The function returns a Promise which returns the GuildChannel class once it's fulfilled.

setPosition

guildChannel.setPosition(position: number, reason?: string) : Promise<GuildChannel>;

Changes the position of the channel comparing to other channels in the same category. The function returns a Promise which returns the GuildChannel class once it's fulfilled.

setParent

guildChannel.setParent(parent: CategoryChannel | string, reason?: string) : Promise<GuildChannel>;

Changes the category the channel is in. The function returns a Promise which returns the GuildChannel class once it's fulfilled.

lockPermissions

guildChannel.lockPermissions() : Promise<GuildChannel>;

Syncs the permissions of the category where the channel is placed in with the channel. The function returns a Promise which returns the GuildChannel class once it's fulfilled.

permissionsFor

guildChannel.permissionsFor(resolvableMemberOrRole: User | Member | Role | string) : PermissionsBitField;

Gets the permissions for a member or role in the channel. The function returns the Discord.js PermissionsBitField class which includes the permissions the member or role has.

setSlowMode

guildChannel.setSlowMode(dateResolvable: string | Date | number, reason?: string) : Promise<GuildChannel>;

Changes the slow mode for the channel. The function returns a Promise which returns the GuildChannel class once it's fulfilled.

createInvite

guildChannel.createInvite(options: object) : Promise<Invite>;

Creates a new invite for this channel with settings based on the information provided in the options argument. The function returns a Promise which returns an instance of the Invite class once it has been fulfilled.

The options object may contain the following information:

  • temporary: A boolean which defines whether members that joined via the invite should be automatically kicked after 24 hours if they have not yet received a role

  • maxAge: A number which defines the amount of milliseconds the invite is valid. Use 0 if you want the invite to last forever.

  • maxUses: A number which defines how many times the invite may be used before it automatically should be removed. Use 0 if you want no limit of uses.

  • unique: A boolean which defines whether the bot should forcebly create a new invite with these settings or may also use an existing invite with the same settings.

  • targetUser: Whose stream users should automatically watch when they use the invite. (A user must be streaming in a voice channel. Members using this invite will automatically view the stream when they join the server of this user when this user is the targetUser.)

  • targetApplication: Which embedded application should be opened when a member joins a server. (An application such as YouTube Together is being played in a voice channel. Members will automatically join this application activity when the targetApplication has been set to the id of this application.) (The id of the application)

  • targetType: The type of target for a voice channel invite (Stream, Application or EmbeddedApplication)

  • reason: The reason you want to create a new invite for this channel. This must be a string between 1-512 characters, but is not required.

Last updated