Guild

Represents the data stored in the database, is different from the Discord.js Guild.

Constructor

new Guild(client, data)

Parameters:
NameTypeDescription
clientDiscord.ClientThe Discord Client.
dataGuildDataThe data to create the guild with.

Members

achievements :AchievementManager

- The manager for the achievements.

guildId :Discord.Snowflake

- The ID of the guild.
Type:
  • Discord.Snowflake

guildName :string

- The name of the guild.
Type:
  • string

ranks :RankManager

- The manager for the ranks.

users :UserManager

- The manager for the users.

Methods

(async) appendAchievement(achievement) → {Promise.<Achievement>}

Add an achievement to the guild data and update it the database.
Parameters:
NameTypeDescription
achievementAchievementBuilderThe achievement to add.
Throws:
  • - If the achievement is missing.
    Type
    MissingValue
  • - If the achievement is not an AchievementBuilder instance.
    Type
    InvalidValue
  • - If the achievement name is already in use.
    Type
    DuplicateAchievement
Returns:
- The achievement added.
Type: 
Promise.<Achievement>

(async) appendRank(rank) → {Promise.<Rank>}

Add a rank to the guild data and update it the database.
Parameters:
NameTypeDescription
rankRankBuilderThe rank to add.
Throws:
  • - If the rank is missing.
    Type
    MissingValue
  • - If the rank is not a RankBuilder instance.
    Type
    InvalidValue
  • - If the rank priority is already in use.
    Type
    RankPriorityInUse
Returns:
- The rank added.
Type: 
Promise.<Rank>

(async) removeAchievement(name) → {Promise.<Achievement>}

Remove an achievement from the guild data and update it the database. **NOTE: When an achievement is removed, it is removed from all users.**
Parameters:
NameTypeDescription
nameStringThe name of the achievement to remove.
Returns:
- The achievement removed.
Type: 
Promise.<Achievement>

(async) removeRank(priority) → {Promise.<Rank>}

Remove a rank from the guild data and update it the database.
Parameters:
NameTypeDescription
priorityNumberThe priority of the rank to remove.
Returns:
- The rank removed.
Type: 
Promise.<Rank>

toJSON() → {GuildData}

Convert the guild data to a JSON object used for saving to the database.
Returns:
Type: 
GuildData