Guild class

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

constructor

The Guild class requires two arguments. The first argument must be an instance of the Discord.js Guild class which provides the data for the guild. The second argument must be an instance of the Zyno Bot Addons Addon class and defines the addon where the guild class should be created for.

Properties

addon

An instance of the Zyno Bot Addons Addon class which represents the addon the guild class was created for.

id

The id of the guild and is a Twitter snowflake.

name

The name of the guild.

channels

An instance of the Save class and provides the channels which are available for the bot in the guild.

Save<channelId, TextChannel | VoiceChannel | CategoryChannel | StageChannel | DirectoryChannel | ForumChannel | ThreadChannel>

emojis

An instance of the Save class and provides the emojis created in the guild.

Save<emojiId, Emoji>

iconURL

The url of the icon the guild uses.

description

The server description which was set and can be seen in the server discovery tab on Discord.

owner

An instance of the Member class and represents the owner of the guild.

ownerId

The user id of the owner of the guild.

members

An instance of the Save class and provides the members in the guild.

Save<userId, Member>

memberCount

A number which represents the amount of members in the server.

invites

An instance of the Save class and provides the invites created for this guild.

Save<inviteCode, Invite>

verified

A boolean which defines whether the guild is verified or not.

verificationLevel

A number which represents the verification level which is set in the guild.

boosts

The amount of boosts the server has.

roles

An instance of the Save class which provides the roles of the guild.

Save<roleId, Role>

everyoneRole

An instance of the Role class which represents the everyone role.

moderationRoles

An instance of the Save class which provides the moderation roles set for the bot.

Save<roleId, Role>

ticketRoles

An instance of the Save class which provides the ticket roles set for the bot.

Save<roleId, Role>

joinRoles

An instance of the Save class which provides the join roles set for the bot.

Save<roleId, Role>

botAdded

An instance of the built-in NodeJS Date class which represents the time the bot got added in the server.

botAddedTimestamp

A number which represents the timestamp of the time when the bot got added in the server.

created

An instance of the built-in NodeJS Date class which represents the time when the server was created.

createdTimestamp

A number which represents the timestamp of the time when the server was created.

voiceStates

An instance of the Save class which provides the voice states inside the server of each member.

Save<userId, VoiceState>

Functions

setName

guild.setName(name: string) : Promise<Guild>;

Changes the name of the guild. The function returns a Promise which returns an instance of the Guild class with the updated data once the name has been changed.

setIcon

guild.setIcon(iconUrl: string, reason?: string) : Promise<Guild>;

Changes the icon of the guild. The function returns a Promise which returns an instance of the Guild class with the updated data once the icon has been changed.

setBanner

guild.setBanner(bannerUrl: string, reason?: string) : Promise<Guild>;

Changes the banner of the guild. The function returns a Promise which returns an instance of the Guild class with the updated data once the banner has been changed.

ban

guild.ban(member: Member | string, reason?: string) : Promise<Guild>;

Bans a member from the guild. The function returns a Promise which returns an instance of the Guild class with the updated data once the member has been banned.

unban

guild.unban(userId: string, reason?: string) : Promise<Guild>;

Unbans a user from the guild. The function returns a Promise which returns an instance of the Guild class with the updated data once the member has been unbanned.

createEmoji

guild.createEmoji(options: object) : Promise<void>;

Creates a new emoji for the guild. The function returns a Promise which gets fulfilled once the emoji has been created.

The options object may contain the following information:

  • name: The name you'd like to give the emoji.

  • imageUrl: The url of the image you'd like the emoji to use.

  • reason: The reason you want to create an emoji for the guild. This must be a string between 1-512 characters, but is not required.

deleteEmoji

guild.deleteEmoji(emoji: Emoji | string, reason?: string) : Promise<void>;

Deletes an emoji from the guild. The function returns a Promise which gets fulfilled once the emoji has been deleted.

createRole

guild.createRole(options: object) : Promise<Role>;

Creates a new role for the guild. The function returns a Promise which returns an instance of the Role class which represents the new role once the role has been created.

The options object may contain the following information:

  • name: The name you'd like to give to the role.

  • color: A number which represents the base10 color code or a string which represents the HEX color code of the color you'd like to give to the role.

  • position: A number which represents the position the role should get in comparison with the other roles where 0 is the highest position.

  • hoist: A boolean which represents whether the role should be displayed separately from the members.

  • permissions: An array with the permissions members with this role should have. The permissions which can be used can be found on the permissionsBitfield page.

  • reason: The reason you want to create the role. This must be a string between 1-512 characters, but is not required.

deleteRole

guild.deleteRole(role: Role | string, reason?: string) : Promise<void>;

Deletes a role from the guild. The function returns a Promise which gets fulfilled once the role has been deleted.

createChannel

guild.createChannel(options: object) : Promise<TextChannel | CategoryChannel | VoiceChannel | StageChannel | ForumChannel | DirectoryChannel>;

Creates a new channel for the guild. The function returns a Promise which returns an instance of the TextChannel, CategoryChannel, VoiceChannel, StageChannel, ForumChannel or DirectoryChannel class, depending on the type which was provided in the options, once the channel has been created.

The options object may contain the following data:

  • name: A string which represents the new name of the channel. The name must be between 1-100 characters and is required to provide.

  • type: The type of channel to create. This must be GuildText, GuildVoice, GuildCategory, GuildAnnouncement, GuildStageVoice, GuildDirectory or GuildForum.

  • parent: An instance of the CategoryChannel class or a string which represents the id of a category channel which represents the category where the channel should be placed under. This cannot be used when creating a new category channel.

  • topic: A string between 1-100 characters which tells what the channel is meant for.

  • nsfw: A boolean which defines whether the channel should be marked as NSFW or not.

  • bitrate: The quality of the audio in kbps when creating a voice or stage channel.

  • userLimit: The amount of members who are allowed to join the channel when creating a voice or stage channel.

  • videoQuality: A string which is either Full or Auto or a number which represents one of these above mentioned options and represents the default video quality in the voice or stage channel. 1 represents Auto and 2 represents Full.

  • rtcRegion: The region you want to change the voice region of the voice channel to. The regions you can use hasn't been specified by the Discord API docs, but can be found by using it's endpoint according to the docs (more info).

  • position: The position compared to the other channels within the same category channel where the channel should be placed. The highest position is 0.

  • slowMode: The time the users have to wait before they can send another message after sending a message in the channel. This must be a number which defines the time in miliseconds, an instance of the Date class where the timestamp gets substracted of the current timestamp and the difference is used as the slow mode time or a string which defines the time like 1 hour.

  • autoArchiveThreads: The time it takes before thread channels created within the channel automatically archives after inactivity when creating a text or forum channel. This must be a number which defines the time in miliseconds, an instance of the Date class where the timestamp gets substracted of the current timestamp and the difference is used as the auto archive duration or a string which defines the time like 1 hour. The duration must be an hour, a day, 3 days or a week.

  • permissions: An array which includes JSON objects. Every object should have a key named id where the value is the id of the role or member the permissions apply to. Every object should either have a key named allow or deny (both are also allowed) where the value is an array with the permissions as bigints the member or role should or shouldn't have (you can also use the permissionsBitfield object instead of writing the bigints). It is optional to add a type key where the value is member , user or role which represents whether the id belongs to a member/user or a role.

  • reason: The reason you want to create a channel in the guild. This must be a string between 1-512 characters.

Last updated