Skip to content

Commit

Permalink
feat(Client): add guildAvailable event (#9692)
Browse files Browse the repository at this point in the history
* feat(Client): add `guildAvailable` event

* refactor: sort entries alphabetically

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
kyranet and kodiakhq[bot] authored Jul 15, 2023
1 parent 4141405 commit 3c85fb2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ module.exports = (client, { d: data }, shard) => {
if (!guild.available && !data.unavailable) {
// A newly available guild
guild._patch(data);

/**
* Emitted whenever a guild becomes available.
* @event Client#guildAvailable
* @param {Guild} guild The guild that became available
*/
client.emit(Events.GuildAvailable, guild);
}
} else {
// A new guild
Expand Down
2 changes: 2 additions & 0 deletions packages/discord.js/src/util/Events.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @property {string} Debug debug
* @property {string} Error error
* @property {string} GuildAuditLogEntryCreate guildAuditLogEntryCreate
* @property {string} GuildAvailable guildAvailable
* @property {string} GuildBanAdd guildBanAdd
* @property {string} GuildBanRemove guildBanRemove
* @property {string} GuildCreate guildCreate
Expand Down Expand Up @@ -97,6 +98,7 @@ module.exports = {
Debug: 'debug',
Error: 'error',
GuildAuditLogEntryCreate: 'guildAuditLogEntryCreate',
GuildAvailable: 'guildAvailable',
GuildBanAdd: 'guildBanAdd',
GuildBanRemove: 'guildBanRemove',
GuildCreate: 'guildCreate',
Expand Down
2 changes: 2 additions & 0 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4807,6 +4807,7 @@ export interface ClientEvents {
emojiUpdate: [oldEmoji: GuildEmoji, newEmoji: GuildEmoji];
error: [error: Error];
guildAuditLogEntryCreate: [auditLogEntry: GuildAuditLogsEntry, guild: Guild];
guildAvailable: [guild: Guild];
guildBanAdd: [ban: GuildBan];
guildBanRemove: [ban: GuildBan];
guildCreate: [guild: Guild];
Expand Down Expand Up @@ -5015,6 +5016,7 @@ export enum Events {
AutoModerationRuleUpdate = 'autoModerationRuleUpdate',
ClientReady = 'ready',
GuildAuditLogEntryCreate = 'guildAuditLogEntryCreate',
GuildAvailable = 'guildAvailable',
GuildCreate = 'guildCreate',
GuildDelete = 'guildDelete',
GuildUpdate = 'guildUpdate',
Expand Down

0 comments on commit 3c85fb2

Please sign in to comment.