From 474aa2fa6e806fc8f136ad6d6ee1abc33caf6022 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 00:06:48 -0300 Subject: [PATCH 01/70] feat: initial structure --- esm.mjs | 3 +- index.js | 1 + lib/Client.js | 70 +++++++++++++++++++ lib/Constants.js | 20 +++++- lib/gateway/Shard.js | 75 ++++++++++++++++++++ lib/rest/Endpoints.js | 2 + lib/structures/Guild.js | 17 +++++ lib/structures/GuildEvent.js | 129 +++++++++++++++++++++++++++++++++++ 8 files changed, 314 insertions(+), 3 deletions(-) create mode 100644 lib/structures/GuildEvent.js diff --git a/esm.mjs b/esm.mjs index 810e5eb01..159cb99ac 100644 --- a/esm.mjs +++ b/esm.mjs @@ -45,5 +45,6 @@ export const { VoiceChannel, VoiceConnection, VoiceConnectionManager, - VoiceState + VoiceState, + GuildEvent } = Eris; diff --git a/index.js b/index.js index fee8b34d7..f2af9d353 100644 --- a/index.js +++ b/index.js @@ -47,5 +47,6 @@ Eris.VoiceChannel = require("./lib/structures/VoiceChannel"); Eris.VoiceConnection = require("./lib/voice/VoiceConnection"); Eris.VoiceConnectionManager = require("./lib/voice/VoiceConnectionManager"); Eris.VoiceState = require("./lib/structures/VoiceState"); +Eris.GuildEvent = require("./lib/structures/GuildEvent"); module.exports = Eris; diff --git a/lib/Client.js b/lib/Client.js index 3b8593b25..fb5e2adcb 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -12,6 +12,7 @@ const GuildAuditLogEntry = require("./structures/GuildAuditLogEntry"); const GuildIntegration = require("./structures/GuildIntegration"); const GuildPreview = require("./structures/GuildPreview"); const GuildTemplate = require("./structures/GuildTemplate"); +const GuildEvent = require("./structures/GuildEvent"); const Invite = require("./structures/Invite"); const Member = require("./structures/Member"); const Message = require("./structures/Message"); @@ -209,6 +210,7 @@ class Client extends EventEmitter { this.privateChannelMap = {}; this.privateChannels = new Collection(PrivateChannel); this.guildShardMap = {}; + this.guildEventMap = {}; this.unavailableGuilds = new Collection(UnavailableGuild); this.relationships = new Collection(Relationship); this.users = new Collection(User); @@ -2769,6 +2771,74 @@ class Client extends EventEmitter { return this.requestHandler.request("GET", Endpoints.DISCOVERY_VALIDATION + `?term=${encodeURI(term)}`, true); } + /** + * Create a scheduled guild event + * @arg {String} guildID The guild id where the event will be created + * @arg {Object} event The event to be created + * @arg {String} [event.name] The name of the event + * @arg {String} [event.channelID] The channel id of the event + * @arg {String} [event.privacyLevel] The privacy level of the event + * @arg {String} [event.scheduledStartTime] The time to schedule the event + * @arg {String} [event.description] The description of the event + * @arg {Number} [event.entityType] The scheduled entity type of the event + * @returns {Promise} + */ + createGuildEvent(guildID, event) { + return this.requestHandler.request("POST", Endpoints.GUILD_EVENT_CREATE(guildID), true, { + channel_id: event.channelID, + name: event.name, + privacy_level: event.privacyLevel, + scheduled_start_time: event.scheduledStartTime, + description: event.description, + entity_type: event.entityType + }).then(data => new GuildEvent(data, this)); + } + + /** + * Get a guild scheduled event data via the REST API. REST mode is required to use this endpoint. + * @arg {String} eventID The id of the event + * @returns {Promise} + */ + getRESTGuildEvent(eventID) { + if(!this.options.restMode) { + return Promise.reject(new Error("Eris REST mode is not enabled")); + } + + return this.requestHandler.request("GET", Endpoints.GUILD_EVENT(eventID), true).then(data => new GuildEvent(data, this)); + } + + /** + * Delete a guild scheduled event + * @arg {String} eventID The event id + * @returns {Promise} + */ + deleteGuildEvent(eventID) { + return this.requestHandler.request("DELETE", Endpoints.GUILD_EVENT(eventID), true); + } + + /** + * Edit a scheduled guild event + * @arg {Object} event The event to be created + * @arg {String} [event.name] The name of the event + * @arg {String} [event.channelID] The channel id of the event + * @arg {String} [event.privacyLevel] The privacy level of the event + * @arg {String} [event.scheduledStartTime] The time to schedule the event + * @arg {String} [event.description] The description of the event + * @arg {Number} [event.entityType] The scheduled entity type of the event + * @arg {String} eventID The event id + * @returns {Promise} + */ + editGuildEvent(event, eventID) { + return this.requestHandler.request("POST", Endpoints.GUILD_EVENT(eventID), true, { + channel_id: event.channelID, + name: event.name, + privacy_level: event.privacyLevel, + scheduled_start_time: event.scheduledStartTime, + description: event.description, + entity_type: event.entityType + }).then(data => new GuildEvent(data, this)); + } + _formatAllowedMentions(allowed) { if(!allowed) { return this.options.allowedMentions; diff --git a/lib/Constants.js b/lib/Constants.js index 787cf2091..46bd78724 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -67,7 +67,8 @@ const Permissions = { manageEmojisAndStickers: 1n << 30n, manageEmojis: 1n << 30n, // [DEPRECATED] useApplicationCommands: 1n << 31n, useSlashCommands: 1n << 31n, // [DEPRECATED] voiceRequestToSpeak: 1n << 32n, - useExternalStickers: 1n << 37n + useExternalStickers: 1n << 37n, + manageEvents: 1n << 33n }; Permissions.allGuild = Permissions.kickMembers | Permissions.banMembers @@ -80,7 +81,8 @@ Permissions.allGuild = Permissions.kickMembers | Permissions.manageNicknames | Permissions.manageRoles | Permissions.manageWebhooks - | Permissions.manageEmojisAndStickers; + | Permissions.manageEmojisAndStickers + | Permissions.manageEvents; Permissions.allText = Permissions.createInstantInvite | Permissions.manageChannels | Permissions.addReactions @@ -279,3 +281,17 @@ module.exports.Intents = { directMessageReactions: 1 << 13, directMessageTyping: 1 << 14 }; + +module.exports.GuildEventStatus = { + SCHEDULED: 1, + ACTIVE: 2, + COMPLETED: 3, + CANCELED: 4 +}; + +module.exports.GuildEventEntityTypes = { + NONE: 0, + STAGE_INSTANCE: 1, + VOICE: 2, + LOCATION: 3 +}; diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 70c4bd78f..327e5031d 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -14,6 +14,7 @@ const ExtendedUser = require("../structures/ExtendedUser"); const User = require("../structures/User"); const Invite = require("../structures/Invite"); const Constants = require("../Constants"); +const GuildEvent = require("../structures/GuildEvent"); const WebSocket = typeof window !== "undefined" ? require("../util/BrowserWebSocket") : require("ws"); @@ -2071,6 +2072,80 @@ class Shard extends EventEmitter { this.client.userGuildSettings[packet.d.guild_id] = packet.d; break; } + case "GUILD_SCHEDULED_EVENT_CREATE": { + const event = new GuildEvent(packet.d, this.client); + + const guild = this.client.guilds.get(packet.d.guild_id); + if(!guild) { + this.emit("debug", `Missing guild ${packet.d.guild_id} in GUILD_SCHEDULED_EVENT_CREATE`); + break; + } + + guild.events.add(packet.d, this.client); + this.client.guildEventMap[packet.d.id] = packet.d.guild_id; + + /** + * Fired when a scheduled guild event is created + * @event Client#guildEventCreate + * @prop {GuildEvent} event The event + */ + this.emit("guildEventCreate", event); + break; + } + case "GUILD_SCHEDULED_EVENT_UPDATE": { + const guild = this.client.guilds.get(packet.d.guild_id); + const event = guild.events.get(packet.d.id); + + if(!event) { + this.emit("guildEventUpdate", guild.threads.add(packet.d, this.client), null); + this.client.guildEventMap[packet.d.id] = packet.d.guild_id; + } + + const oldEvent = { + channelID: packet.d.channel_id, + name: packet.d.name, + privacyLevel: packet.d.privacy_level, + scheduledStartTime: new Date(packet.d.scheduled_start_time), + description: packet.d.description, + entityType: packet.d.entity_type + }; + event.update(packet.d); + + /** + * Fired when a scheduled guild event is updated + * @event Client#guildEventUpdate + * @prop {GuildEvent} event The updated event + * @prop {?Object} oldEvent The old guild event. This will be null if the event was uncached + * @prop {String} oldEvent.channelID The channel id of the event + * @prop {String} oldEvent.name The name of the event + * @prop {Number} oldEvent.privacyLevel The privacy level of the event + * @prop {Date} oldEventscheduledStartTime The time to schedule the event + * @prop {String} oldEvent.description The description of the event + * @prop {Number} oldEvent.entityType The scheduled entity type of the event + */ + this.emit("guildEventUpdate", event, oldEvent); + break; + } + case "GUILD_SCHEDULED_EVENT_DELETE": { + delete this.client.guildEventMap[packet.d.id]; + const guild = this.client.guilds.get(packet.d.guild_id); + + if(!guild) { + this.emit("debug", `Missing guild ${packet.d.guild_id} in GUILD_SCHEDULED_EVENT_DELETE`); + break; + } + const event = guild.events.remove(packet.d); + if(!event) { + break; + } + /** + * Fired when a scheduled guild event is deleted + * @event Client#guildEventDelete + * @prop {GuildEvent} event The event that was deleted + */ + this.emit("guildEventDelete", event); + break; + } case "MESSAGE_ACK": // Ignore these case "GUILD_INTEGRATIONS_UPDATE": case "USER_SETTINGS_UPDATE": diff --git a/lib/rest/Endpoints.js b/lib/rest/Endpoints.js index c36d1a7db..400e7026d 100644 --- a/lib/rest/Endpoints.js +++ b/lib/rest/Endpoints.js @@ -64,6 +64,7 @@ module.exports.GUILD_WELCOME_SCREEN = (guildID) module.exports.GUILD_WIDGET = (guildID) => `/guilds/${guildID}/widget.json`; module.exports.GUILD_WIDGET_SETTINGS = (guildID) => `/guilds/${guildID}/widget`; module.exports.GUILD_VOICE_STATE = (guildID, user) => `/guilds/${guildID}/voice-states/${user}`; +module.exports.GUILD_EVENT_CREATE = (guildID) => `/guilds/${guildID}/events`; module.exports.GUILDS = "/guilds"; module.exports.INVITE = (inviteID) => `/invites/${inviteID}`; module.exports.OAUTH2_APPLICATION = (appID) => `/oauth2/applications/${appID}`; @@ -90,6 +91,7 @@ module.exports.WEBHOOK_MESSAGE = (hookID, token, msgID) module.exports.WEBHOOK_SLACK = (hookID) => `/webhooks/${hookID}/slack`; module.exports.WEBHOOK_TOKEN = (hookID, token) => `/webhooks/${hookID}/${token}`; module.exports.WEBHOOK_TOKEN_SLACK = (hookID, token) => `/webhooks/${hookID}/${token}/slack`; +module.exports.GUILD_EVENT = (eventID) => `/guild-events/${eventID}`; // CDN Endpoints module.exports.ACHIEVEMENT_ICON = (applicationID, achievementID, icon) => `/app-assets/${applicationID}/achievements/${achievementID}/icons/${icon}`; diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index a44b6e357..f5cc5d9a3 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -9,6 +9,7 @@ const Member = require("./Member"); const Role = require("./Role"); const VoiceState = require("./VoiceState"); const Permission = require("./Permission"); +const GuildEvent = require("./GuildEvent"); const {Permissions} = require("../Constants"); /** @@ -82,6 +83,7 @@ class Guild extends Base { this.voiceStates = new Collection(VoiceState); this.channels = new Collection(GuildChannel); this.members = new Collection(Member); + this.events = new Collection(GuildEvent); this.memberCount = data.member_count; this.roles = new Collection(Role); this.applicationID = data.application_id; @@ -988,6 +990,21 @@ class Guild extends Base { return this._client.unbanGuildMember.call(this._client, this.id, userID, reason); } + /** + * Create a scheduled guild event in this guild + * @arg {Object} event The event to be created + * @arg {String} [event.name] The name of the event + * @arg {String} [event.channelID] The channel id of the event + * @arg {String} [event.privacyLevel] The privacy level of the event + * @arg {String} [event.scheduledStartTime] The time to schedule the event + * @arg {String} [event.description] The description of the event + * @arg {Number} [event.entityType] The scheduled entity type of the event + * @returns {Promise} + */ + createEvent(event) { + return this._client.createGuildEvent.call(this._client, this.id, event); + } + toJSON(props = []) { return super.toJSON([ "afkChannelID", diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js new file mode 100644 index 000000000..8bbb10a45 --- /dev/null +++ b/lib/structures/GuildEvent.js @@ -0,0 +1,129 @@ +"use strict"; + +const Base = require("./Base"); + +/** +* Represents a guild scheduled event +* @prop {String} id The id of the guild event +* @prop {String} guildID The guild id of the event +* @prop {String} channelID The channel id of the event +* @prop {String} name The name of the event +* @prop {String} description The description of the event +* @prop {String} image The image hash of the event +* @prop {Date} scheduledStartTime The date the event will start +* @prop {Date} scheduledEndTime The time the event will end, or null if the event does not have a scheduled time to end +* @prop {Number} privacyLevel Event privacy level +* @prop {Number} status The scheduled status of the event +* @prop {Number} entityType The scheduled entity type of the event +* @prop {String} entityID Entity id +* @prop {Boolean} entityMetadata Metadata for the event +* @prop {Array} entityMetadata.speakerIDS The speakers of the stage channel +* @prop {String} entityMetadata.location Location of the event +* @prop {Array} skuIDs Sku ids +* @prop {Array} skus Skus +* @prop {Number} userCount Users subscribed to the event +*/ +class GuildEvent extends Base { + constructor(data, client) { + super(data.id); + + this._client = client; + this.scheduledEndTime = null; + this.update(data); + } + + update(data) { + if(data.guild_id !== undefined) { + this.guildID = data.guild_id; + } + if(data.channel_id !== undefined) { + this.channelID = data.channel_id; + } + if(data.name !== undefined) { + this.name = data.name; + } + if(data.description !== undefined) { + this.description = data.description; + } + if(data.image !== undefined) { + this.image = data.image; + } + if(data.scheduled_start_time !== undefined) { + this.scheduledStartTime = new Date(data.scheduled_start_time); + } + if(data.scheduled_end_time !== undefined) { + this.scheduledEndTime = new Date(data.scheduled_end_time); + } + if(data.privacy_level !== undefined) { + this.privacyLevel = data.privacy_level; + } + if(data.status !== undefined) { + this.status = data.status; + } + if(data.entity_type !== undefined) { + this.entityType = data.entity_type; + } + if(data.entity_id !== undefined) { + this.entityID = data.entity_id; + } + if(data.entity_metadata !== undefined) { + this.entityMetadata = {speakerIDS: data.speaker_ids, location: data.location}; + } + if(data.sku_ids !== undefined) { + this.skuIDs = data.sku_ids; + } + if(data.skus !== undefined && data.skus.length > 0) { + this.skus = data.skus; + } + if(data.user_count !== undefined) { + this.userCount = data.user_count; + } + } + + /** + * Delete this scheduled event + * @returns {Promise} + */ + delete() { + return this._client.deleteGuildEvent.call(this._client, this.id); + } + + /** + * Edit this scheduled event + * @arg {String} guildID The guild id where the event will be created + * @arg {Object} event The event to be created + * @arg {String} [event.name] The name of the event + * @arg {String} [event.channelID] The channel id of the event + * @arg {String} [event.privacyLevel] The privacy level of the event + * @arg {String} [event.scheduledStartTime] The time to schedule the event + * @arg {String} [event.description] The description of the event + * @arg {Number} [event.entityType] The scheduled entity type of the event + * @returns {Promise} + */ + edit(event) { + return this._client.editGuildEvent.call(this._client, event, this.id); + } + + toJSON(props = []) { + return super.toJSON([ + "guildID", + "channelID", + "name", + "description", + "image", + "scheduledStartTime", + "scheduledEndTime", + "privacyLevel", + "status", + "entityType", + "entityID", + "entityMetadata", + "skuIDs", + "skus", + "userCount", + ...props + ]); + } +} + +module.exports = GuildEvent; From be21548e7b8a8cccdffad10b2b321ac0a4056a2e Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 00:19:06 -0300 Subject: [PATCH 02/70] chore: update typing name --- lib/structures/GuildEvent.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index 8bbb10a45..7ae44b94c 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -8,7 +8,7 @@ const Base = require("./Base"); * @prop {String} guildID The guild id of the event * @prop {String} channelID The channel id of the event * @prop {String} name The name of the event -* @prop {String} description The description of the event +* @prop {String?} description The description of the event * @prop {String} image The image hash of the event * @prop {Date} scheduledStartTime The date the event will start * @prop {Date} scheduledEndTime The time the event will end, or null if the event does not have a scheduled time to end @@ -16,12 +16,12 @@ const Base = require("./Base"); * @prop {Number} status The scheduled status of the event * @prop {Number} entityType The scheduled entity type of the event * @prop {String} entityID Entity id -* @prop {Boolean} entityMetadata Metadata for the event +* @prop {Object} entityMetadata Metadata for the event * @prop {Array} entityMetadata.speakerIDS The speakers of the stage channel * @prop {String} entityMetadata.location Location of the event * @prop {Array} skuIDs Sku ids * @prop {Array} skus Skus -* @prop {Number} userCount Users subscribed to the event +* @prop {Number?} userCount Users subscribed to the event */ class GuildEvent extends Base { constructor(data, client) { From ab0e1cba35f57f779cb6712e5ea517fac4c5aace Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 00:19:17 -0300 Subject: [PATCH 03/70] feat: typings for GuildEvent --- index.d.ts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/index.d.ts b/index.d.ts index 4bb8cc93f..e283892b0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -51,6 +51,8 @@ declare namespace Eris { type PossiblyUncachedGuild = Guild | Uncached; type PremiumTier = 0 | 1 | 2 | 3; type VerificationLevel = 0 | 1 | 2 | 3 | 4; + type GuildEventEntityTypes = Constants["GuildEventEntityTypes"][keyof Constants["GuildEventEntityTypes"]]; + type GuildEventStatus = Constants["GuildEventStatus"][keyof Constants["GuildEventStatus"]]; // Message type ActionRowComponents = Button | SelectMenu; @@ -1138,6 +1140,10 @@ declare namespace Eris { team_id: string; user: PartialUser; } + interface GuildEventMetadata { + speakerIDS?: string[]; + location?: string; + } interface Constants { AuditLogActions: { GUILD_UPDATE: 1; @@ -1326,6 +1332,7 @@ declare namespace Eris { allText: 140392266833n; allVoice: 4629464849n; all: 146028888063n; + manageEvents: 8589934592n; }; REST_VERSION: 8; StickerFormats: { @@ -1382,6 +1389,18 @@ declare namespace Eris { RESUMED: 9; DISCONNECT: 13; }; + GuildEventStatus: { + SCHEDULED: 1, + ACTIVE: 2, + COMPLETED: 3, + CANCELED: 4 + }; + GuildEventEntityTypes: { + NONE: 0, + STAGE_INSTANCE: 1, + VOICE: 2, + LOCATION: 3 + }; } // Selfbot @@ -2828,6 +2847,25 @@ declare namespace Eris { suppress: boolean; constructor(data: BaseData); } + + export class GuildEvent extends Base { + id: string; + guildID: string; + channelID: string; + name: string; + description?: string; + image: string; + scheduledStartTime: Date; + scheduledEndTime: Date; + privacyLevel: number; + status: GuildEventStatus; + entityType: GuildEventEntityTypes; + entityID: string; + entityMetadata: GuildEventMetadata; + skuIDs: string[]; + skus: null; + userCount?: number; + } } export = Eris; From 656528550340b70ed4491b8ccb4ec53c343e4195 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 00:23:34 -0300 Subject: [PATCH 04/70] feat: fix option name --- lib/gateway/Shard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 327e5031d..0fe55b2c9 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2119,9 +2119,9 @@ class Shard extends EventEmitter { * @prop {String} oldEvent.channelID The channel id of the event * @prop {String} oldEvent.name The name of the event * @prop {Number} oldEvent.privacyLevel The privacy level of the event - * @prop {Date} oldEventscheduledStartTime The time to schedule the event + * @prop {Date} oldEvent.scheduledStartTime The time to schedule the event * @prop {String} oldEvent.description The description of the event - * @prop {Number} oldEvent.entityType The scheduled entity type of the event + * @prop {Number} oldEvent.entityType The scheduled entity type of the event */ this.emit("guildEventUpdate", event, oldEvent); break; From d859185efdcae406bac47d1b614fa13863c9ac65 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 00:23:42 -0300 Subject: [PATCH 05/70] chore: documment guild events --- index.d.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index e283892b0..91fa052de 100644 --- a/index.d.ts +++ b/index.d.ts @@ -552,6 +552,9 @@ declare namespace Eris { voiceStateUpdate: [member: Member, oldState: OldVoiceState]; warn: [message: string, id: number]; webhooksUpdate: [data: WebhookData]; + guildEventCreate: [event: GuildEvent]; + guildEventUpdate: [event: GuildEvent | null, oldEvent: PartialGuildEvent]; + guildEventDelete: [event: GuildEvent]; } interface ClientEvents extends EventListeners { shardDisconnect: [err: Error | undefined, id: number]; @@ -1142,7 +1145,15 @@ declare namespace Eris { } interface GuildEventMetadata { speakerIDS?: string[]; - location?: string; + location?: string; + } + interface PartialGuildEvent { + channelID: string; + name: string; + privacyLevel: number; + scheduledStartTime: Date; + description: string; + entityType: number } interface Constants { AuditLogActions: { From 652201e824180c165ee040f8ed21beaf05d0cf4e Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 00:26:01 -0300 Subject: [PATCH 06/70] feat: rename IDS to IDs --- index.d.ts | 2 +- lib/structures/GuildEvent.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 91fa052de..e288b7c7e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1144,7 +1144,7 @@ declare namespace Eris { user: PartialUser; } interface GuildEventMetadata { - speakerIDS?: string[]; + speakerIDs?: string[]; location?: string; } interface PartialGuildEvent { diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index 7ae44b94c..eb9b91b8d 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -17,7 +17,7 @@ const Base = require("./Base"); * @prop {Number} entityType The scheduled entity type of the event * @prop {String} entityID Entity id * @prop {Object} entityMetadata Metadata for the event -* @prop {Array} entityMetadata.speakerIDS The speakers of the stage channel +* @prop {Array} entityMetadata.speakerIDs The speakers of the stage channel * @prop {String} entityMetadata.location Location of the event * @prop {Array} skuIDs Sku ids * @prop {Array} skus Skus @@ -67,7 +67,7 @@ class GuildEvent extends Base { this.entityID = data.entity_id; } if(data.entity_metadata !== undefined) { - this.entityMetadata = {speakerIDS: data.speaker_ids, location: data.location}; + this.entityMetadata = {speakerIDs: data.speaker_ids, location: data.location}; } if(data.sku_ids !== undefined) { this.skuIDs = data.sku_ids; From f5b744d431613cfb9b01aa68ca04ee655c5508e4 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 00:26:49 -0300 Subject: [PATCH 07/70] chore: remove extra whitespaces --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index e288b7c7e..9f8232268 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1402,9 +1402,9 @@ declare namespace Eris { }; GuildEventStatus: { SCHEDULED: 1, - ACTIVE: 2, + ACTIVE: 2, COMPLETED: 3, - CANCELED: 4 + CANCELED: 4 }; GuildEventEntityTypes: { NONE: 0, From 149cbaf68a629634dced67a68739389f8fe06de8 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 00:29:19 -0300 Subject: [PATCH 08/70] chore: remove extra whitespaces --- lib/Constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Constants.js b/lib/Constants.js index 46bd78724..b49b3260e 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -284,7 +284,7 @@ module.exports.Intents = { module.exports.GuildEventStatus = { SCHEDULED: 1, - ACTIVE: 2, + ACTIVE: 2, COMPLETED: 3, CANCELED: 4 }; From 75b108e333b5a8d39c1bf0980a80139452f13fd9 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 00:32:19 -0300 Subject: [PATCH 09/70] chore: run lint --- lib/Client.js | 132 +++++++++++++++++++--------------------- lib/structures/Guild.js | 29 +++++---- 2 files changed, 78 insertions(+), 83 deletions(-) diff --git a/lib/Client.js b/lib/Client.js index fb5e2adcb..04a1a698b 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -545,6 +545,28 @@ class Client extends EventEmitter { return this.requestHandler.request("POST", Endpoints.GUILD_EMOJIS(guildID), true, options); } + /** + * Create a scheduled guild event + * @arg {String} guildID The guild id where the event will be created + * @arg {Object} event The event to be created + * @arg {String} [event.name] The name of the event + * @arg {String} [event.channelID] The channel id of the event + * @arg {String} [event.privacyLevel] The privacy level of the event + * @arg {String} [event.scheduledStartTime] The time to schedule the event + * @arg {String} [event.description] The description of the event + * @arg {Number} [event.entityType] The scheduled entity type of the event + * @returns {Promise} + */ + createGuildEvent(guildID, event) { + return this.requestHandler.request("POST", Endpoints.GUILD_EVENT_CREATE(guildID), true, { + channel_id: event.channelID, + name: event.name, + privacy_level: event.privacyLevel, + scheduled_start_time: event.scheduledStartTime, + description: event.description, + entity_type: event.entityType + }).then((data) => new GuildEvent(data, this)); + } /** * Create a guild based on a template. This can only be used with bots in less than 10 guilds * @arg {String} code The template code @@ -757,6 +779,14 @@ class Client extends EventEmitter { }); } + /** + * Delete a guild scheduled event + * @arg {String} eventID The event id + * @returns {Promise} + */ + deleteGuildEvent(eventID) { + return this.requestHandler.request("DELETE", Endpoints.GUILD_EVENT(eventID), true); + } /** * Delete a guild integration * @arg {String} guildID The ID of the guild @@ -1119,6 +1149,28 @@ class Client extends EventEmitter { return this.requestHandler.request("PATCH", Endpoints.GUILD_EMOJI(guildID, emojiID), true, options); } + /** + * Edit a scheduled guild event + * @arg {Object} event The event to be created + * @arg {String} [event.name] The name of the event + * @arg {String} [event.channelID] The channel id of the event + * @arg {String} [event.privacyLevel] The privacy level of the event + * @arg {String} [event.scheduledStartTime] The time to schedule the event + * @arg {String} [event.description] The description of the event + * @arg {Number} [event.entityType] The scheduled entity type of the event + * @arg {String} eventID The event id + * @returns {Promise} + */ + editGuildEvent(event, eventID) { + return this.requestHandler.request("POST", Endpoints.GUILD_EVENT(eventID), true, { + channel_id: event.channelID, + name: event.name, + privacy_level: event.privacyLevel, + scheduled_start_time: event.scheduledStartTime, + description: event.description, + entity_type: event.entityType + }).then((data) => new GuildEvent(data, this)); + } /** * Edit a guild integration * @arg {String} guildID The ID of the guild @@ -2138,6 +2190,18 @@ class Client extends EventEmitter { return this.requestHandler.request("GET", Endpoints.GUILD_EMOJIS(guildID), true); } + /** + * Get a guild scheduled event data via the REST API. REST mode is required to use this endpoint. + * @arg {String} eventID The id of the event + * @returns {Promise} + */ + getRESTGuildEvent(eventID) { + if(!this.options.restMode) { + return Promise.reject(new Error("Eris REST mode is not enabled")); + } + + return this.requestHandler.request("GET", Endpoints.GUILD_EVENT(eventID), true).then((data) => new GuildEvent(data, this)); + } /** * Get a guild's members via the REST API. REST mode is required to use this endpoint. * @arg {String} guildID The ID of the guild @@ -2771,74 +2835,6 @@ class Client extends EventEmitter { return this.requestHandler.request("GET", Endpoints.DISCOVERY_VALIDATION + `?term=${encodeURI(term)}`, true); } - /** - * Create a scheduled guild event - * @arg {String} guildID The guild id where the event will be created - * @arg {Object} event The event to be created - * @arg {String} [event.name] The name of the event - * @arg {String} [event.channelID] The channel id of the event - * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {String} [event.scheduledStartTime] The time to schedule the event - * @arg {String} [event.description] The description of the event - * @arg {Number} [event.entityType] The scheduled entity type of the event - * @returns {Promise} - */ - createGuildEvent(guildID, event) { - return this.requestHandler.request("POST", Endpoints.GUILD_EVENT_CREATE(guildID), true, { - channel_id: event.channelID, - name: event.name, - privacy_level: event.privacyLevel, - scheduled_start_time: event.scheduledStartTime, - description: event.description, - entity_type: event.entityType - }).then(data => new GuildEvent(data, this)); - } - - /** - * Get a guild scheduled event data via the REST API. REST mode is required to use this endpoint. - * @arg {String} eventID The id of the event - * @returns {Promise} - */ - getRESTGuildEvent(eventID) { - if(!this.options.restMode) { - return Promise.reject(new Error("Eris REST mode is not enabled")); - } - - return this.requestHandler.request("GET", Endpoints.GUILD_EVENT(eventID), true).then(data => new GuildEvent(data, this)); - } - - /** - * Delete a guild scheduled event - * @arg {String} eventID The event id - * @returns {Promise} - */ - deleteGuildEvent(eventID) { - return this.requestHandler.request("DELETE", Endpoints.GUILD_EVENT(eventID), true); - } - - /** - * Edit a scheduled guild event - * @arg {Object} event The event to be created - * @arg {String} [event.name] The name of the event - * @arg {String} [event.channelID] The channel id of the event - * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {String} [event.scheduledStartTime] The time to schedule the event - * @arg {String} [event.description] The description of the event - * @arg {Number} [event.entityType] The scheduled entity type of the event - * @arg {String} eventID The event id - * @returns {Promise} - */ - editGuildEvent(event, eventID) { - return this.requestHandler.request("POST", Endpoints.GUILD_EVENT(eventID), true, { - channel_id: event.channelID, - name: event.name, - privacy_level: event.privacyLevel, - scheduled_start_time: event.scheduledStartTime, - description: event.description, - entity_type: event.entityType - }).then(data => new GuildEvent(data, this)); - } - _formatAllowedMentions(allowed) { if(!allowed) { return this.options.allowedMentions; diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index f5cc5d9a3..8b79b1847 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -373,6 +373,20 @@ class Guild extends Base { return this._client.createGuildEmoji.call(this._client, this.id, options, reason); } + /** + * Create a scheduled guild event in this guild + * @arg {Object} event The event to be created + * @arg {String} [event.name] The name of the event + * @arg {String} [event.channelID] The channel id of the event + * @arg {String} [event.privacyLevel] The privacy level of the event + * @arg {String} [event.scheduledStartTime] The time to schedule the event + * @arg {String} [event.description] The description of the event + * @arg {Number} [event.entityType] The scheduled entity type of the event + * @returns {Promise} + */ + createEvent(event) { + return this._client.createGuildEvent.call(this._client, this.id, event); + } /** * Create a guild role * @arg {Object | Role} [options] An object or Role containing the properties to set @@ -990,21 +1004,6 @@ class Guild extends Base { return this._client.unbanGuildMember.call(this._client, this.id, userID, reason); } - /** - * Create a scheduled guild event in this guild - * @arg {Object} event The event to be created - * @arg {String} [event.name] The name of the event - * @arg {String} [event.channelID] The channel id of the event - * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {String} [event.scheduledStartTime] The time to schedule the event - * @arg {String} [event.description] The description of the event - * @arg {Number} [event.entityType] The scheduled entity type of the event - * @returns {Promise} - */ - createEvent(event) { - return this._client.createGuildEvent.call(this._client, this.id, event); - } - toJSON(props = []) { return super.toJSON([ "afkChannelID", From 5dd0cbadf3a4f16e3f2f6d5aeff60fcb73c5fa58 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 00:36:54 -0300 Subject: [PATCH 10/70] chore: run ts lint --- index.d.ts | 110 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 46 deletions(-) diff --git a/index.d.ts b/index.d.ts index 9f8232268..f2e25815b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -500,8 +500,8 @@ declare namespace Eris { channelPinUpdate: [channel: TextableChannel, timestamp: number, oldTimestamp: number]; channelRecipientAdd: [channel: GroupChannel, user: User]; channelRecipientRemove: [channel: GroupChannel, user: User]; - channelUpdate: [channel: AnyGuildChannel, oldChannel: OldGuildChannel | OldGuildTextChannel | OldGuildVoiceChannel] - | [channel: GroupChannel, oldChannel: OldGroupChannel]; + channelUpdate: [channel: AnyGuildChannel, oldChannel: OldGuildChannel | OldGuildTextChannel | OldGuildVoiceChannel] + | [channel: GroupChannel, oldChannel: OldGroupChannel]; connect: [id: number]; debug: [message: string, id: number]; disconnect: []; @@ -541,8 +541,8 @@ declare namespace Eris { relationshipAdd: [relationship: Relationship]; relationshipRemove: [relationship: Relationship]; relationshipUpdate: [relationship: Relationship, oldRelationship: { type: number }]; - typingStart: [channel: GuildTextableChannel | Uncached, user: User | Uncached, member: Member] - | [channel: PrivateChannel | Uncached, user: User | Uncached, member: null]; + typingStart: [channel: GuildTextableChannel | Uncached, user: User | Uncached, member: Member] + | [channel: PrivateChannel | Uncached, user: User | Uncached, member: null]; unavailableGuildCreate: [guild: UnavailableGuild]; unknown: [packet: RawPacket, id: number]; userUpdate: [user: User, oldUser: PartialUser | null]; @@ -1153,7 +1153,7 @@ declare namespace Eris { privacyLevel: number; scheduledStartTime: Date; description: string; - entityType: number + entityType: number; } interface Constants { AuditLogActions: { @@ -1401,16 +1401,16 @@ declare namespace Eris { DISCONNECT: 13; }; GuildEventStatus: { - SCHEDULED: 1, - ACTIVE: 2, - COMPLETED: 3, - CANCELED: 4 + SCHEDULED: 1; + ACTIVE: 2; + COMPLETED: 3; + CANCELED: 4; }; GuildEventEntityTypes: { - NONE: 0, - STAGE_INSTANCE: 1, - VOICE: 2, - LOCATION: 3 + NONE: 0; + STAGE_INSTANCE: 1; + VOICE: 2; + LOCATION: 3; }; } @@ -1792,6 +1792,8 @@ declare namespace Eris { messageID: string, options: MessageWebhookContent ): Promise>; + emit(event: K, ...args: ClientEvents[K]): boolean; + emit(event: string, ...args: any[]): boolean; enableSelfMFATOTP( secret: string, code: string @@ -1896,6 +1898,10 @@ declare namespace Eris { kickGuildMember(guildID: string, userID: string, reason?: string): Promise; leaveGuild(guildID: string): Promise; leaveVoiceChannel(channelID: string): void; + off(event: K, listener: (...args: ClientEvents[K]) => void): this; + off(event: string, listener: (...args: any[]) => void): this; + once(event: K, listener: (...args: ClientEvents[K]) => void): this; + once(event: string, listener: (...args: any[]) => void): this; pinMessage(channelID: string, messageID: string): Promise; pruneMembers(guildID: string, options?: PruneMemberOptions): Promise; purgeChannel(channelID: string, options: PurgeChannelOptions): Promise; @@ -1923,14 +1929,8 @@ declare namespace Eris { unbanGuildMember(guildID: string, userID: string, reason?: string): Promise; unpinMessage(channelID: string, messageID: string): Promise; validateDiscoverySearchTerm(term: string): Promise<{ valid: boolean }>; - emit(event: K, ...args: ClientEvents[K]): boolean; - emit(event: string, ...args: any[]): boolean; on(event: K, listener: (...args: ClientEvents[K]) => void): this; on(event: string, listener: (...args: any[]) => void): this; - once(event: K, listener: (...args: ClientEvents[K]) => void): this; - once(event: string, listener: (...args: any[]) => void): this; - off(event: K, listener: (...args: ClientEvents[K]) => void): this; - off(event: string, listener: (...args: any[]) => void): this; toString(): string; } @@ -2599,11 +2599,17 @@ declare namespace Eris { editStatus(activities?: ActivityPartial[] | ActivityPartial): void; // @ts-ignore: Method override emit(event: string, ...args: any[]): void; + emit(event: K, ...args: ShardEvents[K]): boolean; + emit(event: string, ...args: any[]): boolean; getGuildMembers(guildID: string, timeout: number): void; hardReset(): void; heartbeat(normal?: boolean): void; identify(): void; initializeWS(): void; + off(event: K, listener: (...args: ShardEvents[K]) => void): this; + off(event: string, listener: (...args: any[]) => void): this; + once(event: K, listener: (...args: ShardEvents[K]) => void): this; + once(event: string, listener: (...args: any[]) => void): this; onPacket(packet: RawPacket): void; requestGuildMembers(guildID: string, options?: RequestGuildMembersOptions): Promise; requestGuildSync(guildID: string): void; @@ -2614,14 +2620,20 @@ declare namespace Eris { sendWS(op: number, _data: Record, priority?: boolean): void; syncGuild(guildID: string): void; wsEvent(packet: Required): void; - emit(event: K, ...args: ShardEvents[K]): boolean; - emit(event: string, ...args: any[]): boolean; + + + + + on(event: K, listener: (...args: ShardEvents[K]) => void): this; + + on(event: string, listener: (...args: any[]) => void): this; - once(event: K, listener: (...args: ShardEvents[K]) => void): this; - once(event: string, listener: (...args: any[]) => void): this; - off(event: K, listener: (...args: ShardEvents[K]) => void): this; - off(event: string, listener: (...args: any[]) => void): this; + + + + + toJSON(props?: string[]): JSONCache; } @@ -2650,19 +2662,19 @@ declare namespace Eris { voiceConnections: Collection; volume: number; add(connection: VoiceConnection): void; + emit(event: K, ...args: StreamEvents[K]): boolean; + emit(event: string, ...args: any[]): boolean; + off(event: K, listener: (...args: StreamEvents[K]) => void): this; + off(event: string, listener: (...args: any[]) => void): this; + once(event: K, listener: (...args: StreamEvents[K]) => void): this; + once(event: string, listener: (...args: any[]) => void): this; play(resource: ReadableStream | string, options?: VoiceResourceOptions): void; remove(connection: VoiceConnection): void; setSpeaking(value: boolean): void; setVolume(volume: number): void; stopPlaying(): void; - emit(event: K, ...args: StreamEvents[K]): boolean; - emit(event: string, ...args: any[]): boolean; on(event: K, listener: (...args: StreamEvents[K]) => void): this; on(event: string, listener: (...args: any[]) => void): this; - once(event: K, listener: (...args: StreamEvents[K]) => void): this; - once(event: string, listener: (...args: any[]) => void): this; - off(event: K, listener: (...args: StreamEvents[K]) => void): this; - off(event: string, listener: (...args: any[]) => void): this; } export class StageChannel extends VoiceChannel { @@ -2805,9 +2817,21 @@ declare namespace Eris { constructor(id: string, options?: { shard?: Shard; shared?: boolean; opusOnly?: boolean }); connect(data: VoiceConnectData): NodeJS.Timer | void; disconnect(error?: Error, reconnecting?: boolean): void; + emit(event: K, ...args: VoiceEvents[K]): boolean; + emit(event: string, ...args: any[]): boolean; heartbeat(): void; + + off(event: K, listener: (...args: VoiceEvents[K]) => void): this; + off(event: string, listener: (...args: any[]) => void): this; + once(event: K, listener: (...args: VoiceEvents[K]) => void): this; + once(event: string, listener: (...args: any[]) => void): this; pause(): void; + + + play(resource: ReadableStream | string, options?: VoiceResourceOptions): void; + + receive(type: "opus" | "pcm"): VoiceDataStream; registerReceiveEventHandler(): void; resume(): void; @@ -2817,14 +2841,8 @@ declare namespace Eris { stopPlaying(): void; switchChannel(channelID: string): void; updateVoiceState(selfMute: boolean, selfDeaf: boolean): void; - emit(event: K, ...args: VoiceEvents[K]): boolean; - emit(event: string, ...args: any[]): boolean; on(event: K, listener: (...args: VoiceEvents[K]) => void): this; on(event: string, listener: (...args: any[]) => void): this; - once(event: K, listener: (...args: VoiceEvents[K]) => void): this; - once(event: string, listener: (...args: any[]) => void): this; - off(event: K, listener: (...args: VoiceEvents[K]) => void): this; - off(event: string, listener: (...args: any[]) => void): this; toJSON(props?: string[]): JSONCache; } @@ -2860,21 +2878,21 @@ declare namespace Eris { } export class GuildEvent extends Base { - id: string; - guildID: string; channelID: string; - name: string; description?: string; - image: string; - scheduledStartTime: Date; - scheduledEndTime: Date; - privacyLevel: number; - status: GuildEventStatus; - entityType: GuildEventEntityTypes; entityID: string; entityMetadata: GuildEventMetadata; + entityType: GuildEventEntityTypes; + guildID: string; + id: string; + image: string; + name: string; + privacyLevel: number; + scheduledEndTime: Date; + scheduledStartTime: Date; skuIDs: string[]; skus: null; + status: GuildEventStatus; userCount?: number; } } From 4bb40494df34f6d41be3dcf2710bad317b1046c6 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 00:38:52 -0300 Subject: [PATCH 11/70] chore: remove whitespace --- index.d.ts | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/index.d.ts b/index.d.ts index f2e25815b..60fabac62 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2620,20 +2620,8 @@ declare namespace Eris { sendWS(op: number, _data: Record, priority?: boolean): void; syncGuild(guildID: string): void; wsEvent(packet: Required): void; - - - - - on(event: K, listener: (...args: ShardEvents[K]) => void): this; - - on(event: string, listener: (...args: any[]) => void): this; - - - - - toJSON(props?: string[]): JSONCache; } @@ -2820,18 +2808,12 @@ declare namespace Eris { emit(event: K, ...args: VoiceEvents[K]): boolean; emit(event: string, ...args: any[]): boolean; heartbeat(): void; - off(event: K, listener: (...args: VoiceEvents[K]) => void): this; off(event: string, listener: (...args: any[]) => void): this; once(event: K, listener: (...args: VoiceEvents[K]) => void): this; once(event: string, listener: (...args: any[]) => void): this; pause(): void; - - - play(resource: ReadableStream | string, options?: VoiceResourceOptions): void; - - receive(type: "opus" | "pcm"): VoiceDataStream; registerReceiveEventHandler(): void; resume(): void; From df8ea66408388ba2bc13a14c0d4d62022fe7ff8f Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 01:06:04 -0300 Subject: [PATCH 12/70] fix: rename property to events --- lib/gateway/Shard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 0fe55b2c9..ee0e26b3d 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2097,7 +2097,7 @@ class Shard extends EventEmitter { const event = guild.events.get(packet.d.id); if(!event) { - this.emit("guildEventUpdate", guild.threads.add(packet.d, this.client), null); + this.emit("guildEventUpdate", guild.events.add(packet.d, this.client), null); this.client.guildEventMap[packet.d.id] = packet.d.guild_id; } From fb67aa40f866e372f28cba6c6fc730b5e28f4d51 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 01:07:18 -0300 Subject: [PATCH 13/70] fix: update skus type temp --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 60fabac62..625f65597 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2873,7 +2873,7 @@ declare namespace Eris { scheduledEndTime: Date; scheduledStartTime: Date; skuIDs: string[]; - skus: null; + skus: string[]; status: GuildEventStatus; userCount?: number; } From c40cc0adf4507d57a129f1b7a6ff297f3cae924a Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 09:39:06 -0300 Subject: [PATCH 14/70] fix: suggestions --- index.d.ts | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/index.d.ts b/index.d.ts index 625f65597..09c34f61f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -501,7 +501,7 @@ declare namespace Eris { channelRecipientAdd: [channel: GroupChannel, user: User]; channelRecipientRemove: [channel: GroupChannel, user: User]; channelUpdate: [channel: AnyGuildChannel, oldChannel: OldGuildChannel | OldGuildTextChannel | OldGuildVoiceChannel] - | [channel: GroupChannel, oldChannel: OldGroupChannel]; + | [channel: GroupChannel, oldChannel: OldGroupChannel]; connect: [id: number]; debug: [message: string, id: number]; disconnect: []; @@ -542,7 +542,7 @@ declare namespace Eris { relationshipRemove: [relationship: Relationship]; relationshipUpdate: [relationship: Relationship, oldRelationship: { type: number }]; typingStart: [channel: GuildTextableChannel | Uncached, user: User | Uncached, member: Member] - | [channel: PrivateChannel | Uncached, user: User | Uncached, member: null]; + | [channel: PrivateChannel | Uncached, user: User | Uncached, member: null]; unavailableGuildCreate: [guild: UnavailableGuild]; unknown: [packet: RawPacket, id: number]; userUpdate: [user: User, oldUser: PartialUser | null]; @@ -1792,8 +1792,6 @@ declare namespace Eris { messageID: string, options: MessageWebhookContent ): Promise>; - emit(event: K, ...args: ClientEvents[K]): boolean; - emit(event: string, ...args: any[]): boolean; enableSelfMFATOTP( secret: string, code: string @@ -1898,10 +1896,6 @@ declare namespace Eris { kickGuildMember(guildID: string, userID: string, reason?: string): Promise; leaveGuild(guildID: string): Promise; leaveVoiceChannel(channelID: string): void; - off(event: K, listener: (...args: ClientEvents[K]) => void): this; - off(event: string, listener: (...args: any[]) => void): this; - once(event: K, listener: (...args: ClientEvents[K]) => void): this; - once(event: string, listener: (...args: any[]) => void): this; pinMessage(channelID: string, messageID: string): Promise; pruneMembers(guildID: string, options?: PruneMemberOptions): Promise; purgeChannel(channelID: string, options: PurgeChannelOptions): Promise; @@ -1929,8 +1923,14 @@ declare namespace Eris { unbanGuildMember(guildID: string, userID: string, reason?: string): Promise; unpinMessage(channelID: string, messageID: string): Promise; validateDiscoverySearchTerm(term: string): Promise<{ valid: boolean }>; + emit(event: K, ...args: ClientEvents[K]): boolean; + emit(event: string, ...args: any[]): boolean; on(event: K, listener: (...args: ClientEvents[K]) => void): this; on(event: string, listener: (...args: any[]) => void): this; + once(event: K, listener: (...args: ClientEvents[K]) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + off(event: K, listener: (...args: ClientEvents[K]) => void): this; + off(event: string, listener: (...args: any[]) => void): this; toString(): string; } @@ -2599,17 +2599,11 @@ declare namespace Eris { editStatus(activities?: ActivityPartial[] | ActivityPartial): void; // @ts-ignore: Method override emit(event: string, ...args: any[]): void; - emit(event: K, ...args: ShardEvents[K]): boolean; - emit(event: string, ...args: any[]): boolean; getGuildMembers(guildID: string, timeout: number): void; hardReset(): void; heartbeat(normal?: boolean): void; identify(): void; initializeWS(): void; - off(event: K, listener: (...args: ShardEvents[K]) => void): this; - off(event: string, listener: (...args: any[]) => void): this; - once(event: K, listener: (...args: ShardEvents[K]) => void): this; - once(event: string, listener: (...args: any[]) => void): this; onPacket(packet: RawPacket): void; requestGuildMembers(guildID: string, options?: RequestGuildMembersOptions): Promise; requestGuildSync(guildID: string): void; @@ -2620,8 +2614,14 @@ declare namespace Eris { sendWS(op: number, _data: Record, priority?: boolean): void; syncGuild(guildID: string): void; wsEvent(packet: Required): void; + emit(event: K, ...args: ShardEvents[K]): boolean; + emit(event: string, ...args: any[]): boolean; on(event: K, listener: (...args: ShardEvents[K]) => void): this; on(event: string, listener: (...args: any[]) => void): this; + once(event: K, listener: (...args: ShardEvents[K]) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + off(event: K, listener: (...args: ShardEvents[K]) => void): this; + off(event: string, listener: (...args: any[]) => void): this; toJSON(props?: string[]): JSONCache; } @@ -2650,19 +2650,19 @@ declare namespace Eris { voiceConnections: Collection; volume: number; add(connection: VoiceConnection): void; - emit(event: K, ...args: StreamEvents[K]): boolean; - emit(event: string, ...args: any[]): boolean; - off(event: K, listener: (...args: StreamEvents[K]) => void): this; - off(event: string, listener: (...args: any[]) => void): this; - once(event: K, listener: (...args: StreamEvents[K]) => void): this; - once(event: string, listener: (...args: any[]) => void): this; play(resource: ReadableStream | string, options?: VoiceResourceOptions): void; remove(connection: VoiceConnection): void; setSpeaking(value: boolean): void; setVolume(volume: number): void; stopPlaying(): void; + emit(event: K, ...args: StreamEvents[K]): boolean; + emit(event: string, ...args: any[]): boolean; on(event: K, listener: (...args: StreamEvents[K]) => void): this; on(event: string, listener: (...args: any[]) => void): this; + once(event: K, listener: (...args: StreamEvents[K]) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + off(event: K, listener: (...args: StreamEvents[K]) => void): this; + off(event: string, listener: (...args: any[]) => void): this; } export class StageChannel extends VoiceChannel { @@ -2805,13 +2805,7 @@ declare namespace Eris { constructor(id: string, options?: { shard?: Shard; shared?: boolean; opusOnly?: boolean }); connect(data: VoiceConnectData): NodeJS.Timer | void; disconnect(error?: Error, reconnecting?: boolean): void; - emit(event: K, ...args: VoiceEvents[K]): boolean; - emit(event: string, ...args: any[]): boolean; heartbeat(): void; - off(event: K, listener: (...args: VoiceEvents[K]) => void): this; - off(event: string, listener: (...args: any[]) => void): this; - once(event: K, listener: (...args: VoiceEvents[K]) => void): this; - once(event: string, listener: (...args: any[]) => void): this; pause(): void; play(resource: ReadableStream | string, options?: VoiceResourceOptions): void; receive(type: "opus" | "pcm"): VoiceDataStream; @@ -2823,8 +2817,14 @@ declare namespace Eris { stopPlaying(): void; switchChannel(channelID: string): void; updateVoiceState(selfMute: boolean, selfDeaf: boolean): void; + emit(event: K, ...args: VoiceEvents[K]): boolean; + emit(event: string, ...args: any[]): boolean; on(event: K, listener: (...args: VoiceEvents[K]) => void): this; on(event: string, listener: (...args: any[]) => void): this; + once(event: K, listener: (...args: VoiceEvents[K]) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + off(event: K, listener: (...args: VoiceEvents[K]) => void): this; + off(event: string, listener: (...args: any[]) => void): this; toJSON(props?: string[]): JSONCache; } From 8b8ba84ac44237c34ec11e99d0bddcb811de7f45 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 09:44:55 -0300 Subject: [PATCH 15/70] fix: use ID instead of id --- lib/Client.js | 6 +++--- lib/structures/Guild.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Client.js b/lib/Client.js index 04a1a698b..11f7a1828 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -547,12 +547,12 @@ class Client extends EventEmitter { /** * Create a scheduled guild event - * @arg {String} guildID The guild id where the event will be created + * @arg {String} guildID The guild ID where the event will be created * @arg {Object} event The event to be created * @arg {String} [event.name] The name of the event - * @arg {String} [event.channelID] The channel id of the event + * @arg {String} [event.channelID] The channel ID of the event * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {String} [event.scheduledStartTime] The time to schedule the event + * @arg {String} [event.scheduledStartTime] The time the event will start * @arg {String} [event.description] The description of the event * @arg {Number} [event.entityType] The scheduled entity type of the event * @returns {Promise} diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 8b79b1847..7d50e0cc8 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -379,7 +379,7 @@ class Guild extends Base { * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel id of the event * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {String} [event.scheduledStartTime] The time to schedule the event + * @arg {String} [event.scheduledStartTime] The time the event will start * @arg {String} [event.description] The description of the event * @arg {Number} [event.entityType] The scheduled entity type of the event * @returns {Promise} From 44228da7f7c3b502bce4b7c38cfbc4e8c1ac5979 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 09:45:06 -0300 Subject: [PATCH 16/70] fix: change event name --- lib/gateway/Shard.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index ee0e26b3d..e0fc56797 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2086,10 +2086,10 @@ class Shard extends EventEmitter { /** * Fired when a scheduled guild event is created - * @event Client#guildEventCreate + * @event Client#guildScheduledEventCreate * @prop {GuildEvent} event The event */ - this.emit("guildEventCreate", event); + this.emit("guildScheduledEventCreate", event); break; } case "GUILD_SCHEDULED_EVENT_UPDATE": { @@ -2113,7 +2113,7 @@ class Shard extends EventEmitter { /** * Fired when a scheduled guild event is updated - * @event Client#guildEventUpdate + * @event Client#guildScheduledEventUpdate * @prop {GuildEvent} event The updated event * @prop {?Object} oldEvent The old guild event. This will be null if the event was uncached * @prop {String} oldEvent.channelID The channel id of the event @@ -2123,7 +2123,7 @@ class Shard extends EventEmitter { * @prop {String} oldEvent.description The description of the event * @prop {Number} oldEvent.entityType The scheduled entity type of the event */ - this.emit("guildEventUpdate", event, oldEvent); + this.emit("guildScheduledEventUpdate", event, oldEvent); break; } case "GUILD_SCHEDULED_EVENT_DELETE": { @@ -2140,10 +2140,10 @@ class Shard extends EventEmitter { } /** * Fired when a scheduled guild event is deleted - * @event Client#guildEventDelete + * @event Client#guildScheduledEventDelete * @prop {GuildEvent} event The event that was deleted */ - this.emit("guildEventDelete", event); + this.emit("guildScheduledEventDelete", event); break; } case "MESSAGE_ACK": // Ignore these From 714e775d9b6cf480968bbf1943a157ea227cacdf Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 09:45:15 -0300 Subject: [PATCH 17/70] fix: sort permission by increasing value --- lib/Constants.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Constants.js b/lib/Constants.js index b49b3260e..9b029550a 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -67,8 +67,8 @@ const Permissions = { manageEmojisAndStickers: 1n << 30n, manageEmojis: 1n << 30n, // [DEPRECATED] useApplicationCommands: 1n << 31n, useSlashCommands: 1n << 31n, // [DEPRECATED] voiceRequestToSpeak: 1n << 32n, - useExternalStickers: 1n << 37n, - manageEvents: 1n << 33n + manageEvents: 1n << 33n, + useExternalStickers: 1n << 37n }; Permissions.allGuild = Permissions.kickMembers | Permissions.banMembers From acae845eb82a313ac2aeb3c2d27f5c166d4af44e Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 10:01:35 -0300 Subject: [PATCH 18/70] fix: parse data to UnixTimestamp --- lib/structures/GuildEvent.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index eb9b91b8d..3f05dd34e 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -10,8 +10,8 @@ const Base = require("./Base"); * @prop {String} name The name of the event * @prop {String?} description The description of the event * @prop {String} image The image hash of the event -* @prop {Date} scheduledStartTime The date the event will start -* @prop {Date} scheduledEndTime The time the event will end, or null if the event does not have a scheduled time to end +* @prop {Number} scheduledStartTime The time the event will start +* @prop {Number} scheduledEndTime The time the event will end, or null if the event does not have a scheduled time to end * @prop {Number} privacyLevel Event privacy level * @prop {Number} status The scheduled status of the event * @prop {Number} entityType The scheduled entity type of the event @@ -49,10 +49,10 @@ class GuildEvent extends Base { this.image = data.image; } if(data.scheduled_start_time !== undefined) { - this.scheduledStartTime = new Date(data.scheduled_start_time); + this.scheduledStartTime = Date.parse(data.scheduled_start_time); } if(data.scheduled_end_time !== undefined) { - this.scheduledEndTime = new Date(data.scheduled_end_time); + this.scheduledEndTime = Date.parse(data.scheduled_end_time); } if(data.privacy_level !== undefined) { this.privacyLevel = data.privacy_level; From 8715696035cbb850f96e8f89afdecbfbd0520bc6 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 10:02:03 -0300 Subject: [PATCH 19/70] chore: rename id to ID --- lib/structures/Guild.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 7d50e0cc8..83bff634d 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -377,7 +377,7 @@ class Guild extends Base { * Create a scheduled guild event in this guild * @arg {Object} event The event to be created * @arg {String} [event.name] The name of the event - * @arg {String} [event.channelID] The channel id of the event + * @arg {String} [event.channelID] The channel ID of the event * @arg {String} [event.privacyLevel] The privacy level of the event * @arg {String} [event.scheduledStartTime] The time the event will start * @arg {String} [event.description] The description of the event From e5c36ee21e3b6b6c2cbdf8b3cb1de5eab3547a9b Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 10:03:05 -0300 Subject: [PATCH 20/70] chore: link to discord documentation --- lib/Client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Client.js b/lib/Client.js index 11f7a1828..2b2ce5aa7 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -554,7 +554,7 @@ class Client extends EventEmitter { * @arg {String} [event.privacyLevel] The privacy level of the event * @arg {String} [event.scheduledStartTime] The time the event will start * @arg {String} [event.description] The description of the event - * @arg {Number} [event.entityType] The scheduled entity type of the event + * @arg {Number} [event.entityType] The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event * @returns {Promise} */ createGuildEvent(guildID, event) { From 4f3e74a46a9945ae88c7f83a3274b6d393aba898 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 10:13:14 -0300 Subject: [PATCH 21/70] fix: rename event to guildScheduledEventUpdate --- lib/gateway/Shard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index e0fc56797..a2d441d7e 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2097,7 +2097,7 @@ class Shard extends EventEmitter { const event = guild.events.get(packet.d.id); if(!event) { - this.emit("guildEventUpdate", guild.events.add(packet.d, this.client), null); + this.emit("guildScheduledEventUpdate", guild.events.add(packet.d, this.client), null); this.client.guildEventMap[packet.d.id] = packet.d.guild_id; } From 50830d66db27138bcc9fba401343ba235ecb04b0 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 10:14:25 -0300 Subject: [PATCH 22/70] fix: parse timestamp into an Unix Timestamp --- lib/gateway/Shard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index a2d441d7e..bbed387bf 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2105,7 +2105,7 @@ class Shard extends EventEmitter { channelID: packet.d.channel_id, name: packet.d.name, privacyLevel: packet.d.privacy_level, - scheduledStartTime: new Date(packet.d.scheduled_start_time), + scheduledStartTime: Date.parse(packet.d.scheduled_start_time), description: packet.d.description, entityType: packet.d.entity_type }; From 041d9f5a3aa3461c19801e6d90d48b5231498b7a Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 10:15:55 -0300 Subject: [PATCH 23/70] chore: update prop type --- lib/gateway/Shard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index bbed387bf..14dbbd6f2 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2119,7 +2119,7 @@ class Shard extends EventEmitter { * @prop {String} oldEvent.channelID The channel id of the event * @prop {String} oldEvent.name The name of the event * @prop {Number} oldEvent.privacyLevel The privacy level of the event - * @prop {Date} oldEvent.scheduledStartTime The time to schedule the event + * @prop {Number} oldEvent.scheduledStartTime The time to schedule the event * @prop {String} oldEvent.description The description of the event * @prop {Number} oldEvent.entityType The scheduled entity type of the event */ From 8a27f6dc96b3ebb39897ac71945d6ea5eb89c4a9 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 10:18:31 -0300 Subject: [PATCH 24/70] chore: fix jsdoc --- lib/structures/GuildEvent.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index 3f05dd34e..b42d00aa2 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -90,10 +90,9 @@ class GuildEvent extends Base { /** * Edit this scheduled event - * @arg {String} guildID The guild id where the event will be created * @arg {Object} event The event to be created * @arg {String} [event.name] The name of the event - * @arg {String} [event.channelID] The channel id of the event + * @arg {String} [event.channelID] The channel ID of the event * @arg {String} [event.privacyLevel] The privacy level of the event * @arg {String} [event.scheduledStartTime] The time to schedule the event * @arg {String} [event.description] The description of the event From 7722df4029641010e179e21a72d6149105776d73 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 10:31:11 -0300 Subject: [PATCH 25/70] chore: fix jsdoc and typings --- index.d.ts | 6 +++--- lib/Client.js | 4 ++-- lib/structures/Guild.js | 2 +- lib/structures/GuildEvent.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/index.d.ts b/index.d.ts index 09c34f61f..5bfc7c714 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1151,7 +1151,7 @@ declare namespace Eris { channelID: string; name: string; privacyLevel: number; - scheduledStartTime: Date; + scheduledStartTime: number; description: string; entityType: number; } @@ -2870,8 +2870,8 @@ declare namespace Eris { image: string; name: string; privacyLevel: number; - scheduledEndTime: Date; - scheduledStartTime: Date; + scheduledEndTime: number; + scheduledStartTime: number; skuIDs: string[]; skus: string[]; status: GuildEventStatus; diff --git a/lib/Client.js b/lib/Client.js index 2b2ce5aa7..9397fc42f 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -552,7 +552,7 @@ class Client extends EventEmitter { * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel ID of the event * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {String} [event.scheduledStartTime] The time the event will start + * @arg {Date} [event.scheduledStartTime] The time the event will start * @arg {String} [event.description] The description of the event * @arg {Number} [event.entityType] The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event * @returns {Promise} @@ -1155,7 +1155,7 @@ class Client extends EventEmitter { * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel id of the event * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {String} [event.scheduledStartTime] The time to schedule the event + * @arg {Date} [event.scheduledStartTime] The time to schedule the event * @arg {String} [event.description] The description of the event * @arg {Number} [event.entityType] The scheduled entity type of the event * @arg {String} eventID The event id diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 83bff634d..fbca0c9e4 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -379,7 +379,7 @@ class Guild extends Base { * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel ID of the event * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {String} [event.scheduledStartTime] The time the event will start + * @arg {Date} [event.scheduledStartTime] The time the event will start * @arg {String} [event.description] The description of the event * @arg {Number} [event.entityType] The scheduled entity type of the event * @returns {Promise} diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index b42d00aa2..99506a87c 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -94,7 +94,7 @@ class GuildEvent extends Base { * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel ID of the event * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {String} [event.scheduledStartTime] The time to schedule the event + * @arg {Date} [event.scheduledStartTime] The time to schedule the event * @arg {String} [event.description] The description of the event * @arg {Number} [event.entityType] The scheduled entity type of the event * @returns {Promise} From f08394414e48e7de400b987a9614d82dd600ec0a Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 14:02:27 -0300 Subject: [PATCH 26/70] fix: logic for update event --- lib/gateway/Shard.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 14dbbd6f2..91f74b692 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2094,14 +2094,15 @@ class Shard extends EventEmitter { } case "GUILD_SCHEDULED_EVENT_UPDATE": { const guild = this.client.guilds.get(packet.d.guild_id); - const event = guild.events.get(packet.d.id); + const oldEvent = guild.events.get(packet.d.id); - if(!event) { + if(!oldEvent) { this.emit("guildScheduledEventUpdate", guild.events.add(packet.d, this.client), null); this.client.guildEventMap[packet.d.id] = packet.d.guild_id; + break; } - const oldEvent = { + const event = { channelID: packet.d.channel_id, name: packet.d.name, privacyLevel: packet.d.privacy_level, @@ -2109,19 +2110,19 @@ class Shard extends EventEmitter { description: packet.d.description, entityType: packet.d.entity_type }; - event.update(packet.d); + oldEvent.update(packet.d); /** * Fired when a scheduled guild event is updated * @event Client#guildScheduledEventUpdate - * @prop {GuildEvent} event The updated event - * @prop {?Object} oldEvent The old guild event. This will be null if the event was uncached - * @prop {String} oldEvent.channelID The channel id of the event - * @prop {String} oldEvent.name The name of the event - * @prop {Number} oldEvent.privacyLevel The privacy level of the event - * @prop {Number} oldEvent.scheduledStartTime The time to schedule the event - * @prop {String} oldEvent.description The description of the event - * @prop {Number} oldEvent.entityType The scheduled entity type of the event + * @prop {Object} event The updated event + * @prop {String} event.channelID The channel ID of the event + * @prop {String} event.name The name of the event + * @prop {Number} event.privacyLevel The privacy level of the event + * @prop {Number} event.scheduledStartTime The time to schedule the event + * @prop {String} event.description The description of the event + * @prop {Number} event.entityType The scheduled entity type of the event + * @prop {?GuildEvent} oldEvent The old guild event. This will be null if the event was uncached */ this.emit("guildScheduledEventUpdate", event, oldEvent); break; From 56814ff2520f70fd0d37d1c3671fa666862943f8 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 14:04:08 -0300 Subject: [PATCH 27/70] chore: rename variable to cachedEvent --- lib/gateway/Shard.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 91f74b692..00793ada0 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2094,9 +2094,9 @@ class Shard extends EventEmitter { } case "GUILD_SCHEDULED_EVENT_UPDATE": { const guild = this.client.guilds.get(packet.d.guild_id); - const oldEvent = guild.events.get(packet.d.id); + const cachedEvent = guild.events.get(packet.d.id); - if(!oldEvent) { + if(!cachedEvent) { this.emit("guildScheduledEventUpdate", guild.events.add(packet.d, this.client), null); this.client.guildEventMap[packet.d.id] = packet.d.guild_id; break; @@ -2110,7 +2110,7 @@ class Shard extends EventEmitter { description: packet.d.description, entityType: packet.d.entity_type }; - oldEvent.update(packet.d); + cachedEvent.update(packet.d); /** * Fired when a scheduled guild event is updated @@ -2124,7 +2124,7 @@ class Shard extends EventEmitter { * @prop {Number} event.entityType The scheduled entity type of the event * @prop {?GuildEvent} oldEvent The old guild event. This will be null if the event was uncached */ - this.emit("guildScheduledEventUpdate", event, oldEvent); + this.emit("guildScheduledEventUpdate", event, cachedEvent); break; } case "GUILD_SCHEDULED_EVENT_DELETE": { From 43a254853b37b43da4aa16a336c2602dc5285699 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 14:09:27 -0300 Subject: [PATCH 28/70] chore: add entityType reference link --- lib/Client.js | 2 +- lib/structures/Guild.js | 2 +- lib/structures/GuildEvent.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Client.js b/lib/Client.js index 9397fc42f..0a78cda29 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -1157,7 +1157,7 @@ class Client extends EventEmitter { * @arg {String} [event.privacyLevel] The privacy level of the event * @arg {Date} [event.scheduledStartTime] The time to schedule the event * @arg {String} [event.description] The description of the event - * @arg {Number} [event.entityType] The scheduled entity type of the event + * @arg {Number} [event.entityType] The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event * @arg {String} eventID The event id * @returns {Promise} */ diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index fbca0c9e4..374ddd939 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -381,7 +381,7 @@ class Guild extends Base { * @arg {String} [event.privacyLevel] The privacy level of the event * @arg {Date} [event.scheduledStartTime] The time the event will start * @arg {String} [event.description] The description of the event - * @arg {Number} [event.entityType] The scheduled entity type of the event + * @arg {Number} [event.entityType] The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event * @returns {Promise} */ createEvent(event) { diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index 99506a87c..3ade0da02 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -14,7 +14,7 @@ const Base = require("./Base"); * @prop {Number} scheduledEndTime The time the event will end, or null if the event does not have a scheduled time to end * @prop {Number} privacyLevel Event privacy level * @prop {Number} status The scheduled status of the event -* @prop {Number} entityType The scheduled entity type of the event +* @prop {Number} entityType The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event * @prop {String} entityID Entity id * @prop {Object} entityMetadata Metadata for the event * @prop {Array} entityMetadata.speakerIDs The speakers of the stage channel From a44621fb3be0c14269f69a63c9d121514169538b Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 6 Sep 2021 14:10:40 -0300 Subject: [PATCH 29/70] chore: add status reference link --- lib/structures/GuildEvent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index 3ade0da02..fa57a8faa 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -13,7 +13,7 @@ const Base = require("./Base"); * @prop {Number} scheduledStartTime The time the event will start * @prop {Number} scheduledEndTime The time the event will end, or null if the event does not have a scheduled time to end * @prop {Number} privacyLevel Event privacy level -* @prop {Number} status The scheduled status of the event +* @prop {Number} status The [scheduled status](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-status) of the event * @prop {Number} entityType The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event * @prop {String} entityID Entity id * @prop {Object} entityMetadata Metadata for the event From 8557b81db46b16837b98e129afc1a95f75459d5d Mon Sep 17 00:00:00 2001 From: Loliticos Date: Wed, 8 Sep 2021 11:27:38 -0300 Subject: [PATCH 30/70] feat: guildScheduledEventUser* created --- index.d.ts | 2 ++ lib/gateway/Shard.js | 48 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 5bfc7c714..de115c549 100644 --- a/index.d.ts +++ b/index.d.ts @@ -555,6 +555,8 @@ declare namespace Eris { guildEventCreate: [event: GuildEvent]; guildEventUpdate: [event: GuildEvent | null, oldEvent: PartialGuildEvent]; guildEventDelete: [event: GuildEvent]; + guildScheduledEventUserCreate: [event: GuildEvent, user: User | string]; + guildScheduledEventUserDelete: [event: GuildEvent, user: User | string]; } interface ClientEvents extends EventListeners { shardDisconnect: [err: Error | undefined, id: number]; diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 00793ada0..7b63138c6 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2142,11 +2142,57 @@ class Shard extends EventEmitter { /** * Fired when a scheduled guild event is deleted * @event Client#guildScheduledEventDelete - * @prop {GuildEvent} event The event that was deleted + * @prop {GuildEvent} event The event that was deleted. */ this.emit("guildScheduledEventDelete", event); break; } + case "GUILD_SCHEDULED_EVENT_USER_CREATE": { + const guild = this.client.guildEventMap[packet.d.guild_scheduled_event_id]; + const user = this.client.users.get(packet.d.user_id) || packet.d.user_id; + + if(!guild) { + this.emit("guildScheduledEventUserCreate", packet.d.guild_scheduled_event_id, user); + break; + } + + const event = guild.events.get(packet.d.guild_scheduled_event_id); + if(!event) { + break; + } + + /** + * Fired when an user has subscribed to a Guild Event. + * @event Client#guildScheduledEventUserCreate + * @prop {GuildEvent} event The guild event that the user subscribed to. + * @prop {User | string} user The user that subscribed to the Guild Event. This will be the user ID if the user was uncached + */ + this.emit("guildScheduledEventUserCreate", event, user); + break; + } + case "GUILD_SCHEDULED_EVENT_USER_DELETE": { + const guild = this.client.guildEventMap[packet.d.guild_scheduled_event_id]; + const user = this.client.users.get(packet.d.user_id) || packet.d.user_id; + + if(!guild) { + this.emit("guildScheduledEventUserDelete", packet.d.guild_scheduled_event_id, user); + break; + } + + const event = guild.events.get(packet.d.guild_scheduled_event_id); + if(!event) { + break; + } + + /** + * Fired when an user has unsubscribed from a Guild Event. + * @event Client#guildScheduledEventUserDelete + * @prop {GuildEvent} event The guild event that the user unsubscribed to. + * @prop {User | string} user The user that unsubscribed to the Guild Event. This will be the user ID if the user was uncached + */ + this.emit("guildScheduledEventUserDelete", event, user); + break; + } case "MESSAGE_ACK": // Ignore these case "GUILD_INTEGRATIONS_UPDATE": case "USER_SETTINGS_UPDATE": From 0e2c7fb77145cbd26b4eaa25be9df90d9e070789 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Wed, 8 Sep 2021 11:29:52 -0300 Subject: [PATCH 31/70] chore: fix documentation --- index.d.ts | 4 ++-- lib/gateway/Shard.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index de115c549..e471d4b47 100644 --- a/index.d.ts +++ b/index.d.ts @@ -555,8 +555,8 @@ declare namespace Eris { guildEventCreate: [event: GuildEvent]; guildEventUpdate: [event: GuildEvent | null, oldEvent: PartialGuildEvent]; guildEventDelete: [event: GuildEvent]; - guildScheduledEventUserCreate: [event: GuildEvent, user: User | string]; - guildScheduledEventUserDelete: [event: GuildEvent, user: User | string]; + guildScheduledEventUserCreate: [event: GuildEvent | string, user: User | string]; + guildScheduledEventUserDelete: [event: GuildEvent | string, user: User | string]; } interface ClientEvents extends EventListeners { shardDisconnect: [err: Error | undefined, id: number]; diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 7b63138c6..340068647 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2164,7 +2164,7 @@ class Shard extends EventEmitter { /** * Fired when an user has subscribed to a Guild Event. * @event Client#guildScheduledEventUserCreate - * @prop {GuildEvent} event The guild event that the user subscribed to. + * @prop {GuildEvent} event The guild event that the user subscribed to. This will be the guild event ID if the guild was uncached * @prop {User | string} user The user that subscribed to the Guild Event. This will be the user ID if the user was uncached */ this.emit("guildScheduledEventUserCreate", event, user); @@ -2187,7 +2187,7 @@ class Shard extends EventEmitter { /** * Fired when an user has unsubscribed from a Guild Event. * @event Client#guildScheduledEventUserDelete - * @prop {GuildEvent} event The guild event that the user unsubscribed to. + * @prop {GuildEvent} event The guild event that the user unsubscribed to. This will be the guild event ID if the guild was uncached * @prop {User | string} user The user that unsubscribed to the Guild Event. This will be the user ID if the user was uncached */ this.emit("guildScheduledEventUserDelete", event, user); From 4025aa736f95fc6b16a9e1892f36c226d99c6647 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Wed, 8 Sep 2021 11:30:32 -0300 Subject: [PATCH 32/70] documentation: add string union type --- lib/gateway/Shard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 340068647..a3ed5651a 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2164,7 +2164,7 @@ class Shard extends EventEmitter { /** * Fired when an user has subscribed to a Guild Event. * @event Client#guildScheduledEventUserCreate - * @prop {GuildEvent} event The guild event that the user subscribed to. This will be the guild event ID if the guild was uncached + * @prop {GuildEvent | string} event The guild event that the user subscribed to. This will be the guild event ID if the guild was uncached * @prop {User | string} user The user that subscribed to the Guild Event. This will be the user ID if the user was uncached */ this.emit("guildScheduledEventUserCreate", event, user); @@ -2187,7 +2187,7 @@ class Shard extends EventEmitter { /** * Fired when an user has unsubscribed from a Guild Event. * @event Client#guildScheduledEventUserDelete - * @prop {GuildEvent} event The guild event that the user unsubscribed to. This will be the guild event ID if the guild was uncached + * @prop {GuildEvent | string} event The guild event that the user unsubscribed to. This will be the guild event ID if the guild was uncached * @prop {User | string} user The user that unsubscribed to the Guild Event. This will be the user ID if the user was uncached */ this.emit("guildScheduledEventUserDelete", event, user); From 6286e76f6fb7eb13f940cf0826ca3fcf359132a5 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Wed, 8 Sep 2021 11:41:51 -0300 Subject: [PATCH 33/70] fix: make event a new GuildEvent --- index.d.ts | 6 +++--- lib/gateway/Shard.js | 17 ++--------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/index.d.ts b/index.d.ts index e471d4b47..c92236096 100644 --- a/index.d.ts +++ b/index.d.ts @@ -552,9 +552,9 @@ declare namespace Eris { voiceStateUpdate: [member: Member, oldState: OldVoiceState]; warn: [message: string, id: number]; webhooksUpdate: [data: WebhookData]; - guildEventCreate: [event: GuildEvent]; - guildEventUpdate: [event: GuildEvent | null, oldEvent: PartialGuildEvent]; - guildEventDelete: [event: GuildEvent]; + guildScheduledEventCreate: [event: GuildEvent]; + guildScheduledEventUpdate: [event: GuildEvent, oldEvent: PartialGuildEvent | null]; + guildScheduledEventDelete: [event: GuildEvent]; guildScheduledEventUserCreate: [event: GuildEvent | string, user: User | string]; guildScheduledEventUserDelete: [event: GuildEvent | string, user: User | string]; } diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index a3ed5651a..844a5a260 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2102,26 +2102,13 @@ class Shard extends EventEmitter { break; } - const event = { - channelID: packet.d.channel_id, - name: packet.d.name, - privacyLevel: packet.d.privacy_level, - scheduledStartTime: Date.parse(packet.d.scheduled_start_time), - description: packet.d.description, - entityType: packet.d.entity_type - }; + const event = new GuildEvent(packet.d, this.client); cachedEvent.update(packet.d); /** * Fired when a scheduled guild event is updated * @event Client#guildScheduledEventUpdate - * @prop {Object} event The updated event - * @prop {String} event.channelID The channel ID of the event - * @prop {String} event.name The name of the event - * @prop {Number} event.privacyLevel The privacy level of the event - * @prop {Number} event.scheduledStartTime The time to schedule the event - * @prop {String} event.description The description of the event - * @prop {Number} event.entityType The scheduled entity type of the event + * @prop {GuildEvent} event The updated event * @prop {?GuildEvent} oldEvent The old guild event. This will be null if the event was uncached */ this.emit("guildScheduledEventUpdate", event, cachedEvent); From 128ec9ffde662a958eb4c5c54f0fdef22df7554b Mon Sep 17 00:00:00 2001 From: Loliticos Date: Thu, 9 Sep 2021 12:12:50 -0300 Subject: [PATCH 34/70] fix: update jsdoc --- lib/Client.js | 4 ++-- lib/gateway/Shard.js | 2 +- lib/structures/GuildEvent.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Client.js b/lib/Client.js index 0a78cda29..6ba074fc5 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -1153,12 +1153,12 @@ class Client extends EventEmitter { * Edit a scheduled guild event * @arg {Object} event The event to be created * @arg {String} [event.name] The name of the event - * @arg {String} [event.channelID] The channel id of the event + * @arg {String} [event.channelID] The channel ID of the event * @arg {String} [event.privacyLevel] The privacy level of the event * @arg {Date} [event.scheduledStartTime] The time to schedule the event * @arg {String} [event.description] The description of the event * @arg {Number} [event.entityType] The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event - * @arg {String} eventID The event id + * @arg {String} eventID The event ID * @returns {Promise} */ editGuildEvent(event, eventID) { diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 844a5a260..120543dd5 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2109,7 +2109,7 @@ class Shard extends EventEmitter { * Fired when a scheduled guild event is updated * @event Client#guildScheduledEventUpdate * @prop {GuildEvent} event The updated event - * @prop {?GuildEvent} oldEvent The old guild event. This will be null if the event was uncached + * @prop {?GuildEvent} oldEvent The old guild event, or null if the event wasn't cached. */ this.emit("guildScheduledEventUpdate", event, cachedEvent); break; diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index fa57a8faa..f469e88cf 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -96,7 +96,7 @@ class GuildEvent extends Base { * @arg {String} [event.privacyLevel] The privacy level of the event * @arg {Date} [event.scheduledStartTime] The time to schedule the event * @arg {String} [event.description] The description of the event - * @arg {Number} [event.entityType] The scheduled entity type of the event + * @arg {Number} [event.entityType] The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event * @returns {Promise} */ edit(event) { From d319590d899c680b696579ddcb035c7ff22f3522 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Thu, 9 Sep 2021 12:26:17 -0300 Subject: [PATCH 35/70] fix: update logic and jsdoc --- lib/Client.js | 2 +- lib/gateway/Shard.js | 33 ++++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/lib/Client.js b/lib/Client.js index 6ba074fc5..bebe3e22e 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -1155,7 +1155,7 @@ class Client extends EventEmitter { * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel ID of the event * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {Date} [event.scheduledStartTime] The time to schedule the event + * @arg {Date} [event.scheduledStartTime] The time the event will start * @arg {String} [event.description] The description of the event * @arg {Number} [event.entityType] The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event * @arg {String} eventID The event ID diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 120543dd5..2dcd19eab 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2094,24 +2094,35 @@ class Shard extends EventEmitter { } case "GUILD_SCHEDULED_EVENT_UPDATE": { const guild = this.client.guilds.get(packet.d.guild_id); - const cachedEvent = guild.events.get(packet.d.id); - - if(!cachedEvent) { - this.emit("guildScheduledEventUpdate", guild.events.add(packet.d, this.client), null); - this.client.guildEventMap[packet.d.id] = packet.d.guild_id; - break; + let event = guild.events.get(packet.d.id); + + let oldEvent = null; + + if(event) { + oldEvent = { + channelID: event.channelID, + name: event.name, + privacyLevel: event.privacyLevel, + scheduledStartTime: event.scheduledStartTime, + description: event.description, + entiyType: event.entityType + }; } - - const event = new GuildEvent(packet.d, this.client); - cachedEvent.update(packet.d); + event = guild.events.update(packet.d, this.client); /** * Fired when a scheduled guild event is updated * @event Client#guildScheduledEventUpdate * @prop {GuildEvent} event The updated event - * @prop {?GuildEvent} oldEvent The old guild event, or null if the event wasn't cached. + * @prop {Object?} oldEvent The old guild event data, or null if the event wasn't cached. + * @prop {String} oldEvent.channelID The channel ID of the event + * @prop {String} oldEvent.name The name of the event + * @prop {Number} oldEvent.privacyLevel The privacy level of the event + * @prop {Date} oldEvent.scheduledStartTime The time the event will start + * @prop {String} oldEvent.description The description of the event + * @prop {Number} oldEvent.entityType The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event */ - this.emit("guildScheduledEventUpdate", event, cachedEvent); + this.emit("guildScheduledEventUpdate", event, oldEvent); break; } case "GUILD_SCHEDULED_EVENT_DELETE": { From 5d212d6d4bfc7a362db1d68d9908588d1b40c00d Mon Sep 17 00:00:00 2001 From: Loliticos Date: Thu, 9 Sep 2021 12:29:39 -0300 Subject: [PATCH 36/70] fix: typo --- lib/gateway/Shard.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 2dcd19eab..a27041ce5 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2097,7 +2097,6 @@ class Shard extends EventEmitter { let event = guild.events.get(packet.d.id); let oldEvent = null; - if(event) { oldEvent = { channelID: event.channelID, @@ -2105,7 +2104,7 @@ class Shard extends EventEmitter { privacyLevel: event.privacyLevel, scheduledStartTime: event.scheduledStartTime, description: event.description, - entiyType: event.entityType + entityType: event.entityType }; } event = guild.events.update(packet.d, this.client); From 0e74a88b1a8773b64b936b54c2aec22fae096503 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Thu, 23 Sep 2021 11:29:30 -0300 Subject: [PATCH 37/70] fix: edit instead of create --- lib/structures/GuildEvent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index f469e88cf..e61ccc1c0 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -90,7 +90,7 @@ class GuildEvent extends Base { /** * Edit this scheduled event - * @arg {Object} event The event to be created + * @arg {Object} event The event to be edited * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel ID of the event * @arg {String} [event.privacyLevel] The privacy level of the event From d8a16bc5a455bce2540d975a2cf19cc85609d1e5 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Thu, 23 Sep 2021 11:29:37 -0300 Subject: [PATCH 38/70] typings: document methods --- index.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.d.ts b/index.d.ts index c92236096..d54332993 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1714,6 +1714,7 @@ declare namespace Eris { createGroupChannel(userIDs: string[]): Promise; createGuild(name: string, options?: CreateGuildOptions): Promise; createGuildEmoji(guildID: string, options: EmojiOptions, reason?: string): Promise; + createGuildEvent(guildID: string, event: PartialGuildEvent): Promise; createGuildFromTemplate(code: string, name: string, icon?: string): Promise; createGuildTemplate(guildID: string, name: string, description?: string | null): Promise; createMessage(channelID: string, content: MessageContent, file?: MessageFile | MessageFile[]): Promise; @@ -1724,6 +1725,7 @@ declare namespace Eris { deleteGuild(guildID: string): Promise; deleteGuildDiscoverySubcategory(guildID: string, categoryID: string, reason?: string): Promise; deleteGuildEmoji(guildID: string, emojiID: string, reason?: string): Promise; + deleteGuildEvent(eventID: string): Promise; deleteGuildIntegration(guildID: string, integrationID: string): Promise; deleteGuildTemplate(guildID: string, code: string): Promise; deleteInvite(inviteID: string, reason?: string): Promise; @@ -1760,6 +1762,7 @@ declare namespace Eris { options: { name?: string; roles?: string[] }, reason?: string ): Promise; + editGuildEvent(event: PartialGuildEvent, eventID: string): Promise; editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise; editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise; editGuildTemplate(guildID: string, code: string, options: GuildTemplateOptions): Promise; @@ -1846,6 +1849,7 @@ declare namespace Eris { getRESTGuildChannels(guildID: string): Promise; getRESTGuildEmoji(guildID: string, emojiID: string): Promise; getRESTGuildEmojis(guildID: string): Promise; + getRESTGuildEvent(eventID: string): Promise; getRESTGuildMember(guildID: string, memberID: string): Promise; getRESTGuildMembers(guildID: string, options?: GetRESTGuildMembersOptions): Promise; /** @deprecated */ @@ -2071,6 +2075,7 @@ declare namespace Eris { discoverySplashURL: string | null; emojiCount?: number; emojis: Emoji[]; + events: Collection; explicitContentFilter: ExplicitContentFilter; features: GuildFeatures[]; icon: string | null; @@ -2137,6 +2142,7 @@ declare namespace Eris { /** @deprecated */ createChannel(name: string, type?: number, reason?: string, options?: CreateChannelOptions | string): Promise; createEmoji(options: { image: string; name: string; roles?: string[] }, reason?: string): Promise; + createEvent(event: PartialGuildEvent): Promise; createRole(options: RoleOptions | Role, reason?: string): Promise; createTemplate(name: string, description?: string | null): Promise; delete(): Promise; @@ -2878,6 +2884,8 @@ declare namespace Eris { skus: string[]; status: GuildEventStatus; userCount?: number; + delete(): Promise; + edit(event: PartialGuildEvent): Promise; } } From 7cdf1a3fd66e591ed9446cdb0f6fc753acfdb875 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Thu, 23 Sep 2021 11:33:33 -0300 Subject: [PATCH 39/70] typings: rename PartialGuildEvent to GuildEventOptions --- index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.d.ts b/index.d.ts index d54332993..132b8470b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -553,7 +553,7 @@ declare namespace Eris { warn: [message: string, id: number]; webhooksUpdate: [data: WebhookData]; guildScheduledEventCreate: [event: GuildEvent]; - guildScheduledEventUpdate: [event: GuildEvent, oldEvent: PartialGuildEvent | null]; + guildScheduledEventUpdate: [event: GuildEvent, oldEvent: GuildEventOptions | null]; guildScheduledEventDelete: [event: GuildEvent]; guildScheduledEventUserCreate: [event: GuildEvent | string, user: User | string]; guildScheduledEventUserDelete: [event: GuildEvent | string, user: User | string]; @@ -1149,7 +1149,7 @@ declare namespace Eris { speakerIDs?: string[]; location?: string; } - interface PartialGuildEvent { + interface GuildEventOptions { channelID: string; name: string; privacyLevel: number; @@ -1714,7 +1714,7 @@ declare namespace Eris { createGroupChannel(userIDs: string[]): Promise; createGuild(name: string, options?: CreateGuildOptions): Promise; createGuildEmoji(guildID: string, options: EmojiOptions, reason?: string): Promise; - createGuildEvent(guildID: string, event: PartialGuildEvent): Promise; + createGuildEvent(guildID: string, event: GuildEventOptions): Promise; createGuildFromTemplate(code: string, name: string, icon?: string): Promise; createGuildTemplate(guildID: string, name: string, description?: string | null): Promise; createMessage(channelID: string, content: MessageContent, file?: MessageFile | MessageFile[]): Promise; @@ -1762,7 +1762,7 @@ declare namespace Eris { options: { name?: string; roles?: string[] }, reason?: string ): Promise; - editGuildEvent(event: PartialGuildEvent, eventID: string): Promise; + editGuildEvent(event: GuildEventOptions, eventID: string): Promise; editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise; editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise; editGuildTemplate(guildID: string, code: string, options: GuildTemplateOptions): Promise; @@ -2142,7 +2142,7 @@ declare namespace Eris { /** @deprecated */ createChannel(name: string, type?: number, reason?: string, options?: CreateChannelOptions | string): Promise; createEmoji(options: { image: string; name: string; roles?: string[] }, reason?: string): Promise; - createEvent(event: PartialGuildEvent): Promise; + createEvent(event: GuildEventOptions): Promise; createRole(options: RoleOptions | Role, reason?: string): Promise; createTemplate(name: string, description?: string | null): Promise; delete(): Promise; @@ -2885,7 +2885,7 @@ declare namespace Eris { status: GuildEventStatus; userCount?: number; delete(): Promise; - edit(event: PartialGuildEvent): Promise; + edit(event: GuildEventOptions): Promise; } } From 8a2655abce37f03a55b423e4d8122b2f4198cadf Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 27 Sep 2021 13:53:43 -0300 Subject: [PATCH 40/70] fix: correct description --- lib/structures/GuildEvent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index e61ccc1c0..ec6a00709 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -94,7 +94,7 @@ class GuildEvent extends Base { * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel ID of the event * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {Date} [event.scheduledStartTime] The time to schedule the event + * @arg {Date} [event.scheduledStartTime] The time the event will start * @arg {String} [event.description] The description of the event * @arg {Number} [event.entityType] The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event * @returns {Promise} From 73dfc6e8d9994ba50d3dd196c3af3999f3a75ee5 Mon Sep 17 00:00:00 2001 From: Ammy Date: Wed, 6 Oct 2021 19:02:48 -0300 Subject: [PATCH 41/70] Update Constants.js --- lib/Constants.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Constants.js b/lib/Constants.js index d0b6d987b..835d6bda8 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -297,6 +297,7 @@ module.exports.GuildEventEntityTypes = { STAGE_INSTANCE: 1, VOICE: 2, LOCATION: 3 +}; module.exports.StickerTypes = { STANDARD: 1, From c2ffb7ab63557db2e0f632d648bab8de0fcb2a5f Mon Sep 17 00:00:00 2001 From: Loliticos Date: Thu, 7 Oct 2021 09:51:31 -0300 Subject: [PATCH 42/70] fix: correct permission numbers and position --- index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 7da1b82fb..6e8fb1d69 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1366,12 +1366,12 @@ declare namespace Eris { /** @deprecated */ useSlashCommands: 2147483648n; voiceRequestToSpeak: 4294967296n; + manageEvents: 8589934592n; useExternalStickers: 137438953472n; - allGuild: 2080899262n; + allGuild: 10670833854n; allText: 140392266833n; allVoice: 4629464849n; - all: 146028888063n; - manageEvents: 8589934592n; + all: 154618822655n; }; REST_VERSION: 8; StickerTypes: { From 5ae544c933fde9ffd10b673baac63d078f216261 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Thu, 7 Oct 2021 12:04:27 -0300 Subject: [PATCH 43/70] fix: correct position --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 6e8fb1d69..48eab5f1f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -46,13 +46,13 @@ declare namespace Eris { // Guild type DefaultNotifications = 0 | 1; type ExplicitContentFilter = 0 | 1 | 2; + type GuildEventEntityTypes = Constants["GuildEventEntityTypes"][keyof Constants["GuildEventEntityTypes"]]; + type GuildEventStatus = Constants["GuildEventStatus"][keyof Constants["GuildEventStatus"]]; type GuildFeatures = "ANIMATED_ICON" | "BANNER" | "COMMERCE" | "COMMUNITY" | "DISCOVERABLE" | "FEATURABLE" | "INVITE_SPLASH" | "MEMBER_VERIFICATION_GATE_ENABLED" | "NEWS" | "PARTNERED" | "PREVIEW_ENABLED" | "VANITY_URL" | "VERIFIED" | "VIP_REGIONS" | "WELCOME_SCREEN_ENABLED" | "TICKETED_EVENTS_ENABLED" | "MONETIZATION_ENABLED" | "MORE_STICKERS" | "THREE_DAY_THREAD_ARCHIVE" | "SEVEN_DAY_THREAD_ARCHIVE" | "PRIVATE_THREADS"; type NSFWLevel = 0 | 1 | 2 | 3; type PossiblyUncachedGuild = Guild | Uncached; type PremiumTier = 0 | 1 | 2 | 3; type VerificationLevel = 0 | 1 | 2 | 3 | 4; - type GuildEventEntityTypes = Constants["GuildEventEntityTypes"][keyof Constants["GuildEventEntityTypes"]]; - type GuildEventStatus = Constants["GuildEventStatus"][keyof Constants["GuildEventStatus"]]; // Message type ActionRowComponents = Button | SelectMenu; From 9cb8a6766c8c091163f740e823bdc491c9dfd2ed Mon Sep 17 00:00:00 2001 From: Loliticos Date: Sat, 13 Nov 2021 13:20:42 -0300 Subject: [PATCH 44/70] feat: rename events --- index.d.ts | 4 ++-- lib/gateway/Shard.js | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/index.d.ts b/index.d.ts index 220625f4d..357f7c4e3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -558,8 +558,8 @@ declare namespace Eris { guildScheduledEventCreate: [event: GuildEvent]; guildScheduledEventUpdate: [event: GuildEvent, oldEvent: GuildEventOptions | null]; guildScheduledEventDelete: [event: GuildEvent]; - guildScheduledEventUserCreate: [event: GuildEvent | string, user: User | string]; - guildScheduledEventUserDelete: [event: GuildEvent | string, user: User | string]; + guildScheduledEventUserAdd: [event: GuildEvent | string, user: User | string]; + guildScheduledEventUserRemove: [event: GuildEvent | string, user: User | string]; } interface ClientEvents extends EventListeners { shardDisconnect: [err: Error | undefined, id: number]; diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index e8fcdc58c..e8949aa37 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2165,12 +2165,12 @@ class Shard extends EventEmitter { this.emit("guildScheduledEventDelete", event); break; } - case "GUILD_SCHEDULED_EVENT_USER_CREATE": { + case "GUILD_SCHEDULED_EVENT_USER_ADD": { const guild = this.client.guildEventMap[packet.d.guild_scheduled_event_id]; const user = this.client.users.get(packet.d.user_id) || packet.d.user_id; if(!guild) { - this.emit("guildScheduledEventUserCreate", packet.d.guild_scheduled_event_id, user); + this.emit("guildScheduledEventUserAdd", packet.d.guild_scheduled_event_id, user); break; } @@ -2181,19 +2181,19 @@ class Shard extends EventEmitter { /** * Fired when an user has subscribed to a Guild Event. - * @event Client#guildScheduledEventUserCreate + * @event Client#guildScheduledEventUserAdd * @prop {GuildEvent | string} event The guild event that the user subscribed to. This will be the guild event ID if the guild was uncached * @prop {User | string} user The user that subscribed to the Guild Event. This will be the user ID if the user was uncached */ - this.emit("guildScheduledEventUserCreate", event, user); + this.emit("guildScheduledEventUserAdd", event, user); break; } - case "GUILD_SCHEDULED_EVENT_USER_DELETE": { + case "GUILD_SCHEDULED_EVENT_USER_REMOVE": { const guild = this.client.guildEventMap[packet.d.guild_scheduled_event_id]; const user = this.client.users.get(packet.d.user_id) || packet.d.user_id; if(!guild) { - this.emit("guildScheduledEventUserDelete", packet.d.guild_scheduled_event_id, user); + this.emit("guildScheduledEventUserRemove", packet.d.guild_scheduled_event_id, user); break; } @@ -2204,11 +2204,11 @@ class Shard extends EventEmitter { /** * Fired when an user has unsubscribed from a Guild Event. - * @event Client#guildScheduledEventUserDelete + * @event Client#guildScheduledEventUserRemove * @prop {GuildEvent | string} event The guild event that the user unsubscribed to. This will be the guild event ID if the guild was uncached * @prop {User | string} user The user that unsubscribed to the Guild Event. This will be the user ID if the user was uncached */ - this.emit("guildScheduledEventUserDelete", event, user); + this.emit("guildScheduledEventUserRemove", event, user); break; } case "MESSAGE_ACK": // Ignore these From 546b5ace989658a331b3eaef8ea85cb923e3410d Mon Sep 17 00:00:00 2001 From: Loliticos Date: Sat, 13 Nov 2021 13:27:24 -0300 Subject: [PATCH 45/70] feat: add events to audit log --- index.d.ts | 4 ++++ lib/Constants.js | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 357f7c4e3..ee5c3b400 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1232,6 +1232,10 @@ declare namespace Eris { STICKER_CREATE: 90; STICKER_UPDATE: 91; STICKER_DELETE: 92; + + GUILD_SCHEDULED_EVENT_CREATE: 100; + GUILD_SCHEDULED_EVENT_UPDATE: 101; + GUILD_SCHEDULED_EVENT_DELETE: 102; }; ChannelTypes: { GUILD_TEXT: 0; diff --git a/lib/Constants.js b/lib/Constants.js index 835d6bda8..11949d585 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -195,7 +195,11 @@ module.exports.AuditLogActions = { STICKER_CREATE: 90, STICKER_UPDATE: 91, - STICKER_DELETE: 92 + STICKER_DELETE: 92, + + GUILD_SCHEDULED_EVENT_CREATE: 100, + GUILD_SCHEDULED_EVENT_UPDATE: 101, + GUILD_SCHEDULED_EVENT_DELETE: 102 }; module.exports.MessageActivityTypes = { From 01eea12aa044204288d754b319378f871272a728 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Sat, 13 Nov 2021 13:50:37 -0300 Subject: [PATCH 46/70] fix: new line --- index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 00bd03975..ef1fcb12f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -49,7 +49,8 @@ declare namespace Eris { type ExplicitContentFilter = 0 | 1 | 2; type GuildEventEntityTypes = Constants["GuildEventEntityTypes"][keyof Constants["GuildEventEntityTypes"]]; type GuildEventStatus = Constants["GuildEventStatus"][keyof Constants["GuildEventStatus"]]; - type GuildFeatures = "ANIMATED_ICON" | "BANNER" | "COMMERCE" | "COMMUNITY" | "DISCOVERABLE" | "FEATURABLE" | "INVITE_SPLASH" | "MEMBER_VERIFICATION_GATE_ENABLED" | "NEWS" | "PARTNERED" | "PREVIEW_ENABLED" | "ROLE_ICONS" | "VANITY_URL" | "VERIFIED" | "VIP_REGIONS" | "WELCOME_SCREEN_ENABLED" | "TICKETED_EVENTS_ENABLED" | "MONETIZATION_ENABLED" | "MORE_STICKERS" | "THREE_DAY_THREAD_ARCHIVE" | "SEVEN_DAY_THREAD_ARCHIVE" | "PRIVATE_THREADS"; type NSFWLevel = 0 | 1 | 2 | 3; + type GuildFeatures = "ANIMATED_ICON" | "BANNER" | "COMMERCE" | "COMMUNITY" | "DISCOVERABLE" | "FEATURABLE" | "INVITE_SPLASH" | "MEMBER_VERIFICATION_GATE_ENABLED" | "NEWS" | "PARTNERED" | "PREVIEW_ENABLED" | "ROLE_ICONS" | "VANITY_URL" | "VERIFIED" | "VIP_REGIONS" | "WELCOME_SCREEN_ENABLED" | "TICKETED_EVENTS_ENABLED" | "MONETIZATION_ENABLED" | "MORE_STICKERS" | "THREE_DAY_THREAD_ARCHIVE" | "SEVEN_DAY_THREAD_ARCHIVE" | "PRIVATE_THREADS"; + type NSFWLevel = 0 | 1 | 2 | 3; type PossiblyUncachedGuild = Guild | Uncached; type PremiumTier = 0 | 1 | 2 | 3; type VerificationLevel = 0 | 1 | 2 | 3 | 4; From bba17b5fa13e7063f948e1037b696ddb1acd9368 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Sat, 13 Nov 2021 13:57:48 -0300 Subject: [PATCH 47/70] style: run lint --- index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index ef1fcb12f..d938903c8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -49,7 +49,7 @@ declare namespace Eris { type ExplicitContentFilter = 0 | 1 | 2; type GuildEventEntityTypes = Constants["GuildEventEntityTypes"][keyof Constants["GuildEventEntityTypes"]]; type GuildEventStatus = Constants["GuildEventStatus"][keyof Constants["GuildEventStatus"]]; - type GuildFeatures = "ANIMATED_ICON" | "BANNER" | "COMMERCE" | "COMMUNITY" | "DISCOVERABLE" | "FEATURABLE" | "INVITE_SPLASH" | "MEMBER_VERIFICATION_GATE_ENABLED" | "NEWS" | "PARTNERED" | "PREVIEW_ENABLED" | "ROLE_ICONS" | "VANITY_URL" | "VERIFIED" | "VIP_REGIONS" | "WELCOME_SCREEN_ENABLED" | "TICKETED_EVENTS_ENABLED" | "MONETIZATION_ENABLED" | "MORE_STICKERS" | "THREE_DAY_THREAD_ARCHIVE" | "SEVEN_DAY_THREAD_ARCHIVE" | "PRIVATE_THREADS"; + type GuildFeatures = "ANIMATED_ICON" | "BANNER" | "COMMERCE" | "COMMUNITY" | "DISCOVERABLE" | "FEATURABLE" | "INVITE_SPLASH" | "MEMBER_VERIFICATION_GATE_ENABLED" | "NEWS" | "PARTNERED" | "PREVIEW_ENABLED" | "ROLE_ICONS" | "VANITY_URL" | "VERIFIED" | "VIP_REGIONS" | "WELCOME_SCREEN_ENABLED" | "TICKETED_EVENTS_ENABLED" | "MONETIZATION_ENABLED" | "MORE_STICKERS" | "THREE_DAY_THREAD_ARCHIVE" | "SEVEN_DAY_THREAD_ARCHIVE" | "PRIVATE_THREADS"; type NSFWLevel = 0 | 1 | 2 | 3; type PossiblyUncachedGuild = Guild | Uncached; type PremiumTier = 0 | 1 | 2 | 3; @@ -645,7 +645,7 @@ declare namespace Eris { channelRecipientAdd: [channel: GroupChannel, user: User]; channelRecipientRemove: [channel: GroupChannel, user: User]; channelUpdate: [channel: AnyGuildChannel, oldChannel: OldGuildChannel | OldGuildTextChannel | OldGuildVoiceChannel] - | [channel: GroupChannel, oldChannel: OldGroupChannel]; + | [channel: GroupChannel, oldChannel: OldGroupChannel]; connect: [id: number]; debug: [message: string, id: number]; disconnect: []; @@ -1380,10 +1380,10 @@ declare namespace Eris { STICKER_CREATE: 90; STICKER_UPDATE: 91; STICKER_DELETE: 92; - + GUILD_SCHEDULED_EVENT_CREATE: 100; GUILD_SCHEDULED_EVENT_UPDATE: 101; - GUILD_SCHEDULED_EVENT_DELETE: 102; + GUILD_SCHEDULED_EVENT_DELETE: 102; }; ChannelTypes: { GUILD_TEXT: 0; From 5b4779c10bca8b1bf06a8cec57895bc426ac33c9 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Sat, 13 Nov 2021 13:58:42 -0300 Subject: [PATCH 48/70] fix: extra space --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index d938903c8..c9c05f063 100644 --- a/index.d.ts +++ b/index.d.ts @@ -645,7 +645,7 @@ declare namespace Eris { channelRecipientAdd: [channel: GroupChannel, user: User]; channelRecipientRemove: [channel: GroupChannel, user: User]; channelUpdate: [channel: AnyGuildChannel, oldChannel: OldGuildChannel | OldGuildTextChannel | OldGuildVoiceChannel] - | [channel: GroupChannel, oldChannel: OldGroupChannel]; + | [channel: GroupChannel, oldChannel: OldGroupChannel]; connect: [id: number]; debug: [message: string, id: number]; disconnect: []; From 72d5ceb00e351f3be9ee443a8948b0de34796113 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Sun, 14 Nov 2021 12:57:30 -0300 Subject: [PATCH 49/70] fix: merge conflict --- lib/structures/Guild.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 14d072b61..1d6d00743 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -89,11 +89,8 @@ class Guild extends Base { this.channels = new Collection(GuildChannel); this.threads = new Collection(ThreadChannel); this.members = new Collection(Member); -<<<<<<< HEAD this.events = new Collection(GuildEvent); -======= this.stageInstances = new Collection(StageInstance); ->>>>>>> dev this.memberCount = data.member_count; this.roles = new Collection(Role); this.applicationID = data.application_id; From e2693332eaaedef9f2023e070cabfe6d0277d156 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Sun, 14 Nov 2021 12:58:54 -0300 Subject: [PATCH 50/70] feat: change event position --- lib/gateway/Shard.js | 234 +++++++++++++++++++++---------------------- 1 file changed, 117 insertions(+), 117 deletions(-) diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 38365d92c..ea56593d5 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2102,123 +2102,6 @@ class Shard extends EventEmitter { this.client.userGuildSettings[packet.d.guild_id] = packet.d; break; } - case "GUILD_SCHEDULED_EVENT_CREATE": { - const event = new GuildEvent(packet.d, this.client); - - const guild = this.client.guilds.get(packet.d.guild_id); - if(!guild) { - this.emit("debug", `Missing guild ${packet.d.guild_id} in GUILD_SCHEDULED_EVENT_CREATE`); - break; - } - - guild.events.add(packet.d, this.client); - this.client.guildEventMap[packet.d.id] = packet.d.guild_id; - - /** - * Fired when a scheduled guild event is created - * @event Client#guildScheduledEventCreate - * @prop {GuildEvent} event The event - */ - this.emit("guildScheduledEventCreate", event); - break; - } - case "GUILD_SCHEDULED_EVENT_UPDATE": { - const guild = this.client.guilds.get(packet.d.guild_id); - let event = guild.events.get(packet.d.id); - - let oldEvent = null; - if(event) { - oldEvent = { - channelID: event.channelID, - name: event.name, - privacyLevel: event.privacyLevel, - scheduledStartTime: event.scheduledStartTime, - description: event.description, - entityType: event.entityType - }; - } - event = guild.events.update(packet.d, this.client); - - /** - * Fired when a scheduled guild event is updated - * @event Client#guildScheduledEventUpdate - * @prop {GuildEvent} event The updated event - * @prop {Object?} oldEvent The old guild event data, or null if the event wasn't cached. - * @prop {String} oldEvent.channelID The channel ID of the event - * @prop {String} oldEvent.name The name of the event - * @prop {Number} oldEvent.privacyLevel The privacy level of the event - * @prop {Date} oldEvent.scheduledStartTime The time the event will start - * @prop {String} oldEvent.description The description of the event - * @prop {Number} oldEvent.entityType The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event - */ - this.emit("guildScheduledEventUpdate", event, oldEvent); - break; - } - case "GUILD_SCHEDULED_EVENT_DELETE": { - delete this.client.guildEventMap[packet.d.id]; - const guild = this.client.guilds.get(packet.d.guild_id); - - if(!guild) { - this.emit("debug", `Missing guild ${packet.d.guild_id} in GUILD_SCHEDULED_EVENT_DELETE`); - break; - } - const event = guild.events.remove(packet.d); - if(!event) { - break; - } - /** - * Fired when a scheduled guild event is deleted - * @event Client#guildScheduledEventDelete - * @prop {GuildEvent} event The event that was deleted. - */ - this.emit("guildScheduledEventDelete", event); - break; - } - case "GUILD_SCHEDULED_EVENT_USER_ADD": { - const guild = this.client.guildEventMap[packet.d.guild_scheduled_event_id]; - const user = this.client.users.get(packet.d.user_id) || packet.d.user_id; - - if(!guild) { - this.emit("guildScheduledEventUserAdd", packet.d.guild_scheduled_event_id, user); - break; - } - - const event = guild.events.get(packet.d.guild_scheduled_event_id); - if(!event) { - break; - } - - /** - * Fired when an user has subscribed to a Guild Event. - * @event Client#guildScheduledEventUserAdd - * @prop {GuildEvent | string} event The guild event that the user subscribed to. This will be the guild event ID if the guild was uncached - * @prop {User | string} user The user that subscribed to the Guild Event. This will be the user ID if the user was uncached - */ - this.emit("guildScheduledEventUserAdd", event, user); - break; - } - case "GUILD_SCHEDULED_EVENT_USER_REMOVE": { - const guild = this.client.guildEventMap[packet.d.guild_scheduled_event_id]; - const user = this.client.users.get(packet.d.user_id) || packet.d.user_id; - - if(!guild) { - this.emit("guildScheduledEventUserRemove", packet.d.guild_scheduled_event_id, user); - break; - } - - const event = guild.events.get(packet.d.guild_scheduled_event_id); - if(!event) { - break; - } - - /** - * Fired when an user has unsubscribed from a Guild Event. - * @event Client#guildScheduledEventUserRemove - * @prop {GuildEvent | string} event The guild event that the user unsubscribed to. This will be the guild event ID if the guild was uncached - * @prop {User | string} user The user that unsubscribed to the Guild Event. This will be the user ID if the user was uncached - */ - this.emit("guildScheduledEventUserRemove", event, user); - } case "THREAD_CREATE": { const channel = Channel.from(packet.d, this.client); if(!channel.guild) { @@ -2435,6 +2318,123 @@ class Shard extends EventEmitter { this.emit("stageInstanceDelete", guild.stageInstances.remove(packet.d) || new StageInstance(packet.d, this.client)); break; } + case "GUILD_SCHEDULED_EVENT_CREATE": { + const event = new GuildEvent(packet.d, this.client); + + const guild = this.client.guilds.get(packet.d.guild_id); + if(!guild) { + this.emit("debug", `Missing guild ${packet.d.guild_id} in GUILD_SCHEDULED_EVENT_CREATE`); + break; + } + + guild.events.add(packet.d, this.client); + this.client.guildEventMap[packet.d.id] = packet.d.guild_id; + + /** + * Fired when a scheduled guild event is created + * @event Client#guildScheduledEventCreate + * @prop {GuildEvent} event The event + */ + this.emit("guildScheduledEventCreate", event); + break; + } + case "GUILD_SCHEDULED_EVENT_UPDATE": { + const guild = this.client.guilds.get(packet.d.guild_id); + let event = guild.events.get(packet.d.id); + + let oldEvent = null; + if(event) { + oldEvent = { + channelID: event.channelID, + name: event.name, + privacyLevel: event.privacyLevel, + scheduledStartTime: event.scheduledStartTime, + description: event.description, + entityType: event.entityType + }; + } + event = guild.events.update(packet.d, this.client); + + /** + * Fired when a scheduled guild event is updated + * @event Client#guildScheduledEventUpdate + * @prop {GuildEvent} event The updated event + * @prop {Object?} oldEvent The old guild event data, or null if the event wasn't cached. + * @prop {String} oldEvent.channelID The channel ID of the event + * @prop {String} oldEvent.name The name of the event + * @prop {Number} oldEvent.privacyLevel The privacy level of the event + * @prop {Date} oldEvent.scheduledStartTime The time the event will start + * @prop {String} oldEvent.description The description of the event + * @prop {Number} oldEvent.entityType The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event + */ + this.emit("guildScheduledEventUpdate", event, oldEvent); + break; + } + case "GUILD_SCHEDULED_EVENT_DELETE": { + delete this.client.guildEventMap[packet.d.id]; + const guild = this.client.guilds.get(packet.d.guild_id); + + if(!guild) { + this.emit("debug", `Missing guild ${packet.d.guild_id} in GUILD_SCHEDULED_EVENT_DELETE`); + break; + } + const event = guild.events.remove(packet.d); + if(!event) { + break; + } + /** + * Fired when a scheduled guild event is deleted + * @event Client#guildScheduledEventDelete + * @prop {GuildEvent} event The event that was deleted. + */ + this.emit("guildScheduledEventDelete", event); + break; + } + case "GUILD_SCHEDULED_EVENT_USER_ADD": { + const guild = this.client.guildEventMap[packet.d.guild_scheduled_event_id]; + const user = this.client.users.get(packet.d.user_id) || packet.d.user_id; + + if(!guild) { + this.emit("guildScheduledEventUserAdd", packet.d.guild_scheduled_event_id, user); + break; + } + + const event = guild.events.get(packet.d.guild_scheduled_event_id); + if(!event) { + break; + } + + /** + * Fired when an user has subscribed to a Guild Event. + * @event Client#guildScheduledEventUserAdd + * @prop {GuildEvent | string} event The guild event that the user subscribed to. This will be the guild event ID if the guild was uncached + * @prop {User | string} user The user that subscribed to the Guild Event. This will be the user ID if the user was uncached + */ + this.emit("guildScheduledEventUserAdd", event, user); + break; + } + case "GUILD_SCHEDULED_EVENT_USER_REMOVE": { + const guild = this.client.guildEventMap[packet.d.guild_scheduled_event_id]; + const user = this.client.users.get(packet.d.user_id) || packet.d.user_id; + + if(!guild) { + this.emit("guildScheduledEventUserRemove", packet.d.guild_scheduled_event_id, user); + break; + } + + const event = guild.events.get(packet.d.guild_scheduled_event_id); + if(!event) { + break; + } + + /** + * Fired when an user has unsubscribed from a Guild Event. + * @event Client#guildScheduledEventUserRemove + * @prop {GuildEvent | string} event The guild event that the user unsubscribed to. This will be the guild event ID if the guild was uncached + * @prop {User | string} user The user that unsubscribed to the Guild Event. This will be the user ID if the user was uncached + */ + this.emit("guildScheduledEventUserRemove", event, user); + } case "MESSAGE_ACK": // Ignore these case "GUILD_INTEGRATIONS_UPDATE": case "USER_SETTINGS_UPDATE": From 544b5e34e772fcff8287f6db823febbc3ead4732 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Sun, 14 Nov 2021 17:04:15 -0300 Subject: [PATCH 51/70] fix: remove duplicate permissions --- lib/Constants.js | 89 ------------------------------------------------ 1 file changed, 89 deletions(-) diff --git a/lib/Constants.js b/lib/Constants.js index 2faaf2fa9..715fa5413 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -3,95 +3,6 @@ module.exports.GATEWAY_VERSION = 9; module.exports.REST_VERSION = 9; -const Permissions = { - createInstantInvite: 1n, - kickMembers: 1n << 1n, - banMembers: 1n << 2n, - administrator: 1n << 3n, - manageChannels: 1n << 4n, - manageGuild: 1n << 5n, - addReactions: 1n << 6n, - viewAuditLog: 1n << 7n, viewAuditLogs: 1n << 7n, // [DEPRECATED] - voicePrioritySpeaker: 1n << 8n, - voiceStream: 1n << 9n, stream: 1n << 9n, // [DEPRECATED] - viewChannel: 1n << 10n, readMessages: 1n << 10n, // [DEPRECATED] - sendMessages: 1n << 11n, - sendTTSMessages: 1n << 12n, - manageMessages: 1n << 13n, - embedLinks: 1n << 14n, - attachFiles: 1n << 15n, - readMessageHistory: 1n << 16n, - mentionEveryone: 1n << 17n, - useExternalEmojis: 1n << 18n, externalEmojis: 1n << 18n, // [DEPRECATED] - viewGuildInsights: 1n << 19n, - voiceConnect: 1n << 20n, - voiceSpeak: 1n << 21n, - voiceMuteMembers: 1n << 22n, - voiceDeafenMembers: 1n << 23n, - voiceMoveMembers: 1n << 24n, - voiceUseVAD: 1n << 25n, - changeNickname: 1n << 26n, - manageNicknames: 1n << 27n, - manageRoles: 1n << 28n, - manageWebhooks: 1n << 29n, - manageEmojisAndStickers: 1n << 30n, manageEmojis: 1n << 30n, // [DEPRECATED] - useApplicationCommands: 1n << 31n, useSlashCommands: 1n << 31n, // [DEPRECATED] - voiceRequestToSpeak: 1n << 32n, - manageEvents: 1n << 33n, - manageThreads: 1n << 34n, - createPublicThreads: 1n << 35n, - createPrivateThreads: 1n << 36n, - useExternalStickers: 1n << 37n, - sendMessagesInThreads: 1n << 38n -}; -Permissions.allGuild = Permissions.kickMembers - | Permissions.banMembers - | Permissions.administrator - | Permissions.manageChannels - | Permissions.manageGuild - | Permissions.viewAuditLog - | Permissions.viewGuildInsights - | Permissions.changeNickname - | Permissions.manageNicknames - | Permissions.manageRoles - | Permissions.manageWebhooks - | Permissions.manageEmojisAndStickers - | Permissions.manageEvents; -Permissions.allText = Permissions.createInstantInvite - | Permissions.manageChannels - | Permissions.addReactions - | Permissions.viewChannel - | Permissions.sendMessages - | Permissions.sendTTSMessages - | Permissions.manageMessages - | Permissions.embedLinks - | Permissions.attachFiles - | Permissions.readMessageHistory - | Permissions.mentionEveryone - | Permissions.useExternalEmojis - | Permissions.manageRoles - | Permissions.manageWebhooks - | Permissions.useApplicationCommands - | Permissions.manageThreads - | Permissions.createPublicThreads - | Permissions.createPrivateThreads - | Permissions.useExternalStickers - | Permissions.sendMessagesInThreads; -Permissions.allVoice = Permissions.createInstantInvite - | Permissions.manageChannels - | Permissions.voicePrioritySpeaker - | Permissions.voiceStream - | Permissions.viewChannel - | Permissions.voiceConnect - | Permissions.voiceSpeak - | Permissions.voiceMuteMembers - | Permissions.voiceDeafenMembers - | Permissions.voiceMoveMembers - | Permissions.voiceUseVAD - | Permissions.manageRoles - | Permissions.voiceRequestToSpeak; -Permissions.all = Permissions.allGuild | Permissions.allText | Permissions.allVoice; -module.exports.Permissions = Permissions; module.exports.ActivityTypes = { GAME: 0, STREAMING: 1, From c92fa5b466b442447c6281a1b1861b51f6127783 Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 15 Nov 2021 20:44:50 -0300 Subject: [PATCH 52/70] feat: remove sku properties --- index.d.ts | 2 -- lib/structures/GuildEvent.js | 10 ---------- 2 files changed, 12 deletions(-) diff --git a/index.d.ts b/index.d.ts index 1f054d879..c1f9ac9b1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3686,8 +3686,6 @@ declare namespace Eris { privacyLevel: number; scheduledEndTime: number; scheduledStartTime: number; - skuIDs: string[]; - skus: string[]; status: GuildEventStatus; userCount?: number; delete(): Promise; diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index ec6a00709..5ec4ce49c 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -19,8 +19,6 @@ const Base = require("./Base"); * @prop {Object} entityMetadata Metadata for the event * @prop {Array} entityMetadata.speakerIDs The speakers of the stage channel * @prop {String} entityMetadata.location Location of the event -* @prop {Array} skuIDs Sku ids -* @prop {Array} skus Skus * @prop {Number?} userCount Users subscribed to the event */ class GuildEvent extends Base { @@ -69,12 +67,6 @@ class GuildEvent extends Base { if(data.entity_metadata !== undefined) { this.entityMetadata = {speakerIDs: data.speaker_ids, location: data.location}; } - if(data.sku_ids !== undefined) { - this.skuIDs = data.sku_ids; - } - if(data.skus !== undefined && data.skus.length > 0) { - this.skus = data.skus; - } if(data.user_count !== undefined) { this.userCount = data.user_count; } @@ -117,8 +109,6 @@ class GuildEvent extends Base { "entityType", "entityID", "entityMetadata", - "skuIDs", - "skus", "userCount", ...props ]); From 314b7bd2697d9b5194dee31a2386b59e9c79465f Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 15 Nov 2021 20:55:07 -0300 Subject: [PATCH 53/70] feat: add and remove properties --- index.d.ts | 10 ++++++++-- lib/Constants.js | 5 +++++ lib/structures/GuildEvent.js | 15 ++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/index.d.ts b/index.d.ts index c1f9ac9b1..5bd012eeb 100644 --- a/index.d.ts +++ b/index.d.ts @@ -57,6 +57,7 @@ declare namespace Eris { type DefaultNotifications = Constants["DefaultMessageNotificationLevels"][keyof Constants["DefaultMessageNotificationLevels"]]; type ExplicitContentFilter = Constants["ExplicitContentFilterLevels"][keyof Constants["ExplicitContentFilterLevels"]]; type GuildEventEntityTypes = Constants["GuildEventEntityTypes"][keyof Constants["GuildEventEntityTypes"]]; + type GuildEventPrivacyLevel = Constants["GuildEventPrivacyLevel"][keyof Constants["GuildEventPrivacyLevel"]]; type GuildEventStatus = Constants["GuildEventStatus"][keyof Constants["GuildEventStatus"]]; type GuildFeatures = Constants["GuildFeatures"][number]; type NSFWLevel = Constants["GuildNSFWLevels"][keyof Constants["GuildNSFWLevels"]]; @@ -1919,6 +1920,10 @@ declare namespace Eris { VOICE: 2; LOCATION: 3; }; + GuildEventPrivacyLevel: { + PUBLIC: 1; + GUILD_ONLY: 2; + }; WebhookTypes: { INCOMING: 1; CHANNEL_FOLLOWER: 2; @@ -3680,13 +3685,14 @@ declare namespace Eris { entityMetadata: GuildEventMetadata; entityType: GuildEventEntityTypes; guildID: string; + creatorID: string; id: string; - image: string; name: string; - privacyLevel: number; + privacyLevel: GuildEventPrivacyLevel; scheduledEndTime: number; scheduledStartTime: number; status: GuildEventStatus; + creator?: User; userCount?: number; delete(): Promise; edit(event: GuildEventOptions): Promise; diff --git a/lib/Constants.js b/lib/Constants.js index 715fa5413..97c9cccb9 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -453,6 +453,11 @@ module.exports.GuildEventEntityTypes = { LOCATION: 3 }; +module.exports.GuildScheduledEventPrivacyLevel = { + PUBLIC: 1, + GUILD_ONLY: 2 +}; + module.exports.PremiumTypes = { NONE: 0, NITRO_CLASSIC: 1, diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index 5ec4ce49c..f15833431 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -1,6 +1,7 @@ "use strict"; const Base = require("./Base"); +const User = require("./User"); /** * Represents a guild scheduled event @@ -9,7 +10,6 @@ const Base = require("./Base"); * @prop {String} channelID The channel id of the event * @prop {String} name The name of the event * @prop {String?} description The description of the event -* @prop {String} image The image hash of the event * @prop {Number} scheduledStartTime The time the event will start * @prop {Number} scheduledEndTime The time the event will end, or null if the event does not have a scheduled time to end * @prop {Number} privacyLevel Event privacy level @@ -19,6 +19,7 @@ const Base = require("./Base"); * @prop {Object} entityMetadata Metadata for the event * @prop {Array} entityMetadata.speakerIDs The speakers of the stage channel * @prop {String} entityMetadata.location Location of the event +* @prop {User} creator The user that created the scheduled event * @prop {Number?} userCount Users subscribed to the event */ class GuildEvent extends Base { @@ -37,15 +38,15 @@ class GuildEvent extends Base { if(data.channel_id !== undefined) { this.channelID = data.channel_id; } + if(data.creator_id !== undefined) { + this.creatorID = data.creator_id; + } if(data.name !== undefined) { this.name = data.name; } if(data.description !== undefined) { this.description = data.description; } - if(data.image !== undefined) { - this.image = data.image; - } if(data.scheduled_start_time !== undefined) { this.scheduledStartTime = Date.parse(data.scheduled_start_time); } @@ -67,6 +68,9 @@ class GuildEvent extends Base { if(data.entity_metadata !== undefined) { this.entityMetadata = {speakerIDs: data.speaker_ids, location: data.location}; } + if(data.creator !== undefined) { + this.creator = new User(data.creator ,this._client); + } if(data.user_count !== undefined) { this.userCount = data.user_count; } @@ -99,9 +103,9 @@ class GuildEvent extends Base { return super.toJSON([ "guildID", "channelID", + "creatorID", "name", "description", - "image", "scheduledStartTime", "scheduledEndTime", "privacyLevel", @@ -109,6 +113,7 @@ class GuildEvent extends Base { "entityType", "entityID", "entityMetadata", + "creator", "userCount", ...props ]); From f17ba6ff6d388a400c5817750c930efe7d72e53f Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 15 Nov 2021 21:23:20 -0300 Subject: [PATCH 54/70] feat: update endpoints --- lib/Client.js | 34 +++++++++++++++++++++++----------- lib/gateway/Shard.js | 1 + lib/rest/Endpoints.js | 5 +++-- lib/structures/Guild.js | 23 ++++++++++++++--------- 4 files changed, 41 insertions(+), 22 deletions(-) diff --git a/lib/Client.js b/lib/Client.js index 34953f440..5edab23cf 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -659,22 +659,32 @@ class Client extends EventEmitter { * @arg {Object} event The event to be created * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel ID of the event + * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event + * @arg {Array} [event.entityMetadata.speakerIDs] The speakers of the stage channel + * @arg {String} [event.entityMetadata.location] Location of the event * @arg {String} [event.privacyLevel] The privacy level of the event * @arg {Date} [event.scheduledStartTime] The time the event will start + * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end * @arg {String} [event.description] The description of the event * @arg {Number} [event.entityType] The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event * @returns {Promise} */ createGuildEvent(guildID, event) { - return this.requestHandler.request("POST", Endpoints.GUILD_EVENT_CREATE(guildID), true, { - channel_id: event.channelID, + return this.requestHandler.request("POST", Endpoints.GUILD_SCHEDULED_EVENTS(guildID), true, { name: event.name, + channel_id: event.channelID, + entity_metadata: { + speaker_ids: event.entityMetadata.speakerIDs, + location: event.entityMetadata.location + }, privacy_level: event.privacyLevel, scheduled_start_time: event.scheduledStartTime, + scheduled_end_time: event.scheduledEndTime, description: event.description, entity_type: event.entityType }).then((data) => new GuildEvent(data, this)); } + /** * Create a guild based on a template. This can only be used with bots in less than 10 guilds * @arg {String} code The template code @@ -688,7 +698,6 @@ class Client extends EventEmitter { icon }).then((guild) => new Guild(guild, this)); } - /** * Create a guild sticker * @arg {Object} options Sticker options @@ -709,7 +718,6 @@ class Client extends EventEmitter { reason: reason }, options.file); } - /** * Create a template for a guild * @arg {String} guildID The ID of the guild @@ -723,7 +731,6 @@ class Client extends EventEmitter { description }).then((template) => new GuildTemplate(template, this)); } - /** * Respond to the interaction with a message * Note: Use webhooks if you have already responded with an interaction response. @@ -748,7 +755,6 @@ class Client extends EventEmitter { createInteractionResponse(interactionID, interactionToken, options, file) { return this.requestHandler.request("POST", Endpoints.INTERACTION_RESPOND(interactionID, interactionToken), true, options, file, "/interactions/:id/:token/callback"); } - /** * Create a message in a channel * Note: If you want to DM someone, the user ID is **not** the DM channel ID. use Client.getDMChannel() to get the DM channel for a user @@ -831,7 +837,6 @@ class Client extends EventEmitter { } return this.requestHandler.request("POST", Endpoints.CHANNEL_MESSAGES(channelID), true, content, file).then((message) => new Message(message, this)); } - /** * Create a guild role * @arg {String} guildID The ID of the guild to create the role in @@ -868,7 +873,6 @@ class Client extends EventEmitter { } }); } - /** * Create a stage instance * @arg {String} channelID The ID of the stage channel to create the instance in @@ -884,7 +888,6 @@ class Client extends EventEmitter { topic: options.topic }).then((instance) => new StageInstance(instance, this)); } - /** * Create a thread with an existing message * @arg {String} channelID The ID of the channel @@ -900,7 +903,6 @@ class Client extends EventEmitter { auto_archive_duration: options.autoArchiveDuration }).then((channel) => Channel.from(channel, this)); } - /** * Create a thread without an existing message * @arg {String} channelID The ID of the channel @@ -919,7 +921,6 @@ class Client extends EventEmitter { type: options.type }).then((channel) => Channel.from(channel, this)); } - /** * Crosspost (publish) a message to subscribed channels * @arg {String} channelID The ID of the NewsChannel @@ -3058,6 +3059,17 @@ class Client extends EventEmitter { this.closeVoiceConnection(this.channelGuildMap[channelID]); } + /** + * List all scheduled events for the given guild. + * @arg {Boolean} withUserCount Include number of users subscribed to each event + * @returns {Promise>} + */ + listGuildEvents(guildID, withUserCount) { + return this.requestHandler.request("GET", Endpoints.GUILD_SCHEDULED_EVENTS(guildID), true, { + with_user_count: withUserCount + }).then((events) => events.map((event) => new GuildEvent(event, this))); + } + /** * Pin a message * @arg {String} channelID The ID of the channel diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 65db58d4a..551e041b1 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2434,6 +2434,7 @@ class Shard extends EventEmitter { * @prop {User | string} user The user that unsubscribed to the Guild Event. This will be the user ID if the user was uncached */ this.emit("guildScheduledEventUserRemove", event, user); + break; } case "MESSAGE_ACK": // Ignore these case "GUILD_INTEGRATIONS_UPDATE": diff --git a/lib/rest/Endpoints.js b/lib/rest/Endpoints.js index 7619ff39f..f4c4abd20 100644 --- a/lib/rest/Endpoints.js +++ b/lib/rest/Endpoints.js @@ -62,6 +62,9 @@ module.exports.GUILD_PREVIEW = (guildID) module.exports.GUILD_PRUNE = (guildID) => `/guilds/${guildID}/prune`; module.exports.GUILD_ROLE = (guildID, roleID) => `/guilds/${guildID}/roles/${roleID}`; module.exports.GUILD_ROLES = (guildID) => `/guilds/${guildID}/roles`; +module.exports.GUILD_SCHEDULED_EVENT = (guildID, scheduledEventID) => `/guilds/${guildID}/scheduled-events/${scheduledEventID}/guild-scheduled-event-object}`; +module.exports.GUILD_SCHEDULED_EVENTS = (guildID) => `/guilds/${guildID}/scheduled-events`; +module.exports.GUILD_SCHEDULED_EVENT_USERS = (guildID, scheduledEventID) => `/guilds/${guildID}/scheduled-events/${scheduledEventID}/guild-scheduled-event-object}/users`; module.exports.GUILD_STICKER = (guildID, stickerID) => `/guilds/${guildID}/stickers/${stickerID}`; module.exports.GUILD_STICKERS = (guildID) => `/guilds/${guildID}/stickers`; module.exports.GUILD_TEMPLATE = (code) => `/guilds/templates/${code}`; @@ -73,7 +76,6 @@ module.exports.GUILD_WELCOME_SCREEN = (guildID) module.exports.GUILD_WIDGET = (guildID) => `/guilds/${guildID}/widget.json`; module.exports.GUILD_WIDGET_SETTINGS = (guildID) => `/guilds/${guildID}/widget`; module.exports.GUILD_VOICE_STATE = (guildID, user) => `/guilds/${guildID}/voice-states/${user}`; -module.exports.GUILD_EVENT_CREATE = (guildID) => `/guilds/${guildID}/events`; module.exports.GUILDS = "/guilds"; module.exports.INTERACTION_RESPOND = (interactID, interactToken) => `/interactions/${interactID}/${interactToken}/callback`; module.exports.INVITE = (inviteID) => `/invites/${inviteID}`; @@ -113,7 +115,6 @@ module.exports.WEBHOOK_MESSAGE = (hookID, token, msgID) module.exports.WEBHOOK_SLACK = (hookID) => `/webhooks/${hookID}/slack`; module.exports.WEBHOOK_TOKEN = (hookID, token) => `/webhooks/${hookID}/${token}`; module.exports.WEBHOOK_TOKEN_SLACK = (hookID, token) => `/webhooks/${hookID}/${token}/slack`; -module.exports.GUILD_EVENT = (eventID) => `/guild-events/${eventID}`; // CDN Endpoints module.exports.ACHIEVEMENT_ICON = (applicationID, achievementID, icon) => `/app-assets/${applicationID}/achievements/${achievementID}/icons/${icon}`; diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 1d6d00743..3b1c7713d 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -437,8 +437,12 @@ class Guild extends Base { * @arg {Object} event The event to be created * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel ID of the event + * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event + * @arg {Array} [event.entityMetadata.speakerIDs] The speakers of the stage channel + * @arg {String} [event.entityMetadata.location] Location of the event * @arg {String} [event.privacyLevel] The privacy level of the event * @arg {Date} [event.scheduledStartTime] The time the event will start + * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end * @arg {String} [event.description] The description of the event * @arg {Number} [event.entityType] The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event * @returns {Promise} @@ -446,6 +450,7 @@ class Guild extends Base { createEvent(event) { return this._client.createGuildEvent.call(this._client, this.id, event); } + /** * Create a guild role * @arg {Object | Role} [options] An object or Role containing the properties to set @@ -462,7 +467,6 @@ class Guild extends Base { createRole(options, reason) { return this._client.createRole.call(this._client, this.id, options, reason); } - /** * Create a guild sticker * @arg {Object} options Sticker options @@ -478,7 +482,6 @@ class Guild extends Base { createSticker(options, reason) { return this._client.createGuildSticker.call(this._client, this.id, options, reason); } - /** * Create a template for this guild * @arg {String} name The name of the template @@ -488,7 +491,6 @@ class Guild extends Base { createTemplate(name, description) { return this._client.createGuildTemplate.call(this._client, this.id, name, description); } - /** * Delete the guild (bot user must be owner) * @returns {Promise} @@ -496,7 +498,6 @@ class Guild extends Base { delete() { return this._client.deleteGuild.call(this._client, this.id); } - /** * Delete a guild application command * @arg {String} commandID The command id @@ -505,7 +506,6 @@ class Guild extends Base { deleteCommand(commandID) { return this._client.deleteGuildCommand.call(this._client, this.id, commandID); } - /** * Delete a discovery subcategory * @arg {String} categoryID The ID of the discovery category @@ -515,7 +515,6 @@ class Guild extends Base { deleteDiscoverySubcategory(categoryID, reason) { return this._client.addGuildDiscoverySubcategory.call(this._client, this.id, categoryID, reason); } - /** * Delete a emoji in the guild * @arg {String} emojiID The ID of the emoji @@ -525,7 +524,6 @@ class Guild extends Base { deleteEmoji(emojiID, reason) { return this._client.deleteGuildEmoji.call(this._client, this.id, emojiID, reason); } - /** * Delete a guild integration * @arg {String} integrationID The ID of the integration @@ -534,7 +532,6 @@ class Guild extends Base { deleteIntegration(integrationID) { return this._client.deleteGuildIntegration.call(this._client, this.id, integrationID); } - /** * Delete a role * @arg {String} roleID The ID of the role @@ -544,7 +541,6 @@ class Guild extends Base { deleteRole(roleID, reason) { return this._client.deleteRole.call(this._client, this.id, roleID, reason); } - /** * Delete a guild sticker * @arg {String} stickerID The ID of the sticker @@ -1108,6 +1104,15 @@ class Guild extends Base { this._client.closeVoiceConnection.call(this._client, this.id); } + /** + * List all scheduled events for this guild. + * @arg {Boolean} withUserCount Include number of users subscribed to each event + * @returns {Promise>} + */ + listEvents(withUserCount) { + return this._client.listGuildEvents.call(this._client, this.id, withUserCount); + } + /** * Get the guild permissions of a member * @arg {String | Member | Object} memberID The ID of the member or a Member object From ce46145324296787ff2b686c52f9d2ef4d10dbfb Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 15 Nov 2021 21:31:01 -0300 Subject: [PATCH 55/70] fix: creator instead of creatorID --- lib/structures/GuildEvent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index f15833431..7b7b24e8a 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -103,7 +103,7 @@ class GuildEvent extends Base { return super.toJSON([ "guildID", "channelID", - "creatorID", + "creator", "name", "description", "scheduledStartTime", From a1bc11595fca42ad1b1b2ccbf7e6f04a6c9be78a Mon Sep 17 00:00:00 2001 From: Loliticos Date: Mon, 15 Nov 2021 21:34:50 -0300 Subject: [PATCH 56/70] feat: remove creatorID --- index.d.ts | 1 - lib/structures/GuildEvent.js | 4 ---- 2 files changed, 5 deletions(-) diff --git a/index.d.ts b/index.d.ts index 5bd012eeb..7424c8037 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3685,7 +3685,6 @@ declare namespace Eris { entityMetadata: GuildEventMetadata; entityType: GuildEventEntityTypes; guildID: string; - creatorID: string; id: string; name: string; privacyLevel: GuildEventPrivacyLevel; diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index 7b7b24e8a..bc9050086 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -38,9 +38,6 @@ class GuildEvent extends Base { if(data.channel_id !== undefined) { this.channelID = data.channel_id; } - if(data.creator_id !== undefined) { - this.creatorID = data.creator_id; - } if(data.name !== undefined) { this.name = data.name; } @@ -103,7 +100,6 @@ class GuildEvent extends Base { return super.toJSON([ "guildID", "channelID", - "creator", "name", "description", "scheduledStartTime", From 076ed2122ebaa705e786ff133076d6a3572769bf Mon Sep 17 00:00:00 2001 From: Loliticos Date: Tue, 16 Nov 2021 14:05:01 -0300 Subject: [PATCH 57/70] feat: updates --- index.d.ts | 26 ++++++++++++------ lib/Client.js | 53 ++++++++++++++++++++++-------------- lib/gateway/Shard.js | 2 +- lib/rest/Endpoints.js | 4 +-- lib/structures/Guild.js | 26 ++++++++++++++++-- lib/structures/GuildEvent.js | 27 +++++++++++++----- 6 files changed, 97 insertions(+), 41 deletions(-) diff --git a/index.d.ts b/index.d.ts index 7424c8037..62fd62c04 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1426,12 +1426,17 @@ declare namespace Eris { location?: string; } interface GuildEventOptions { - channelID: string; name: string; - privacyLevel: number; - scheduledStartTime: number; + channelID: string; + entityMetadata: GuildEventMetadata; + privacyLevel: GuildEventPrivacyLevel; + scheduledStartTime: Date; + scheduledEndTime: Date; description: string; - entityType: number; + entityType: GuildEventEntityTypes; + } + interface GuildEventEditOptions extends GuildEventOptions { + status: GuildEventStatus; } interface Constants { GATEWAY_VERSION: 9; @@ -2255,7 +2260,7 @@ declare namespace Eris { deleteGuildCommand(guildID: string, commandID: string): Promise; deleteGuildDiscoverySubcategory(guildID: string, categoryID: string, reason?: string): Promise; deleteGuildEmoji(guildID: string, emojiID: string, reason?: string): Promise; - deleteGuildEvent(eventID: string): Promise; + deleteGuildEvent(guildID: string, eventID: string): Promise; deleteGuildIntegration(guildID: string, integrationID: string): Promise; deleteGuildSticker(guildID: string, stickerID: string, reason?: string): Promise; deleteGuildTemplate(guildID: string, code: string): Promise; @@ -2297,7 +2302,7 @@ declare namespace Eris { options: { name?: string; roles?: string[] }, reason?: string ): Promise; - editGuildEvent(event: GuildEventOptions, eventID: string): Promise; + editGuildEvent(event: GuildEventEditOptions, eventID: string): Promise; editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise; editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise; editGuildSticker(guildID: string, stickerID: string, options?: EditStickerOptions, reason?: string): Promise; @@ -2401,7 +2406,7 @@ declare namespace Eris { getRESTGuildChannels(guildID: string): Promise; getRESTGuildEmoji(guildID: string, emojiID: string): Promise; getRESTGuildEmojis(guildID: string): Promise; - getRESTGuildEvent(eventID: string): Promise; + getRESTGuildEvent(guildID: string, eventID: string): Promise; getRESTGuildMember(guildID: string, memberID: string): Promise; getRESTGuildMembers(guildID: string, options?: GetRESTGuildMembersOptions): Promise; /** @deprecated */ @@ -2461,6 +2466,8 @@ declare namespace Eris { leaveGuild(guildID: string): Promise; leaveThread(channelID: string, userID?: string): Promise; leaveVoiceChannel(channelID: string): void; + listGuildEvents(guildID: string, withUserCount: boolean): Promise>; + listGuildEventUsers(guildID: string, eventID: string): void; off(event: K, listener: (...args: ClientEvents[K]) => void): this; off(event: string, listener: (...args: any[]) => void): this; once(event: K, listener: (...args: ClientEvents[K]) => void): this; @@ -2773,6 +2780,8 @@ declare namespace Eris { kickMember(userID: string, reason?: string): Promise; leave(): Promise; leaveVoiceChannel(): void; + listEvents(withUserCount: boolean): Promise>; + listEventUsers(eventID: string): void; permissionsOf(memberID: string | Member | MemberRoles): Permission; pruneMembers(options?: PruneMemberOptions): Promise; removeMemberRole(memberID: string, roleID: string, reason?: string): Promise; @@ -3694,7 +3703,8 @@ declare namespace Eris { creator?: User; userCount?: number; delete(): Promise; - edit(event: GuildEventOptions): Promise; + edit(event: GuildEventEditOptions): Promise; + listUsers(): void; } } diff --git a/lib/Client.js b/lib/Client.js index 5edab23cf..1577d6ff0 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -666,8 +666,8 @@ class Client extends EventEmitter { * @arg {Date} [event.scheduledStartTime] The time the event will start * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end * @arg {String} [event.description] The description of the event - * @arg {Number} [event.entityType] The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event - * @returns {Promise} + * @arg {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event + * @returns {Promise} */ createGuildEvent(guildID, event) { return this.requestHandler.request("POST", Endpoints.GUILD_SCHEDULED_EVENTS(guildID), true, { @@ -1019,11 +1019,12 @@ class Client extends EventEmitter { /** * Delete a guild scheduled event + * @arg {String} guildID The guild id of where the event belongs to * @arg {String} eventID The event id * @returns {Promise} */ - deleteGuildEvent(eventID) { - return this.requestHandler.request("DELETE", Endpoints.GUILD_EVENT(eventID), true); + deleteGuildEvent(guildID, eventID) { + return this.requestHandler.request("DELETE", Endpoints.GUILD_SCHEDULED_EVENT(guildID, eventID), true); } /** * Delete a guild integration @@ -1272,7 +1273,6 @@ class Client extends EventEmitter { reason: reason }).then((channel) => Channel.from(channel, this)); } - /** * Create a channel permission overwrite * @arg {String} channelID The ID of channel @@ -1294,7 +1294,6 @@ class Client extends EventEmitter { reason }); } - /** * Edit a guild channel's position. Note that channel position numbers are lowest on top and highest at the bottom. * @arg {String} channelID The ID of the channel @@ -1333,7 +1332,6 @@ class Client extends EventEmitter { parent_id: options.parentID }))); } - /** * Edit a global application command * @arg {String} commandID The command id @@ -1358,7 +1356,6 @@ class Client extends EventEmitter { } return this.requestHandler.request("PATCH", Endpoints.COMMAND(this.application.id, commandID), true, command); } - /** * Edits command permissions for a specific command in a guild. * Note: You can only add up to 10 permission overwrites for a command. @@ -1484,28 +1481,39 @@ class Client extends EventEmitter { options.reason = reason; return this.requestHandler.request("PATCH", Endpoints.GUILD_EMOJI(guildID, emojiID), true, options); } - /** * Edit a scheduled guild event - * @arg {Object} event The event to be created + * @arg {String} guildID The guild ID where the event will be edited + * @arg {String} eventID The id of the scheduled guild event to be edited + * @arg {Object} event The new scheuled guild event object * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel ID of the event + * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event + * @arg {Array} [event.entityMetadata.speakerIDs] The speakers of the stage channel + * @arg {String} [event.entityMetadata.location] Location of the event * @arg {String} [event.privacyLevel] The privacy level of the event * @arg {Date} [event.scheduledStartTime] The time the event will start + * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end * @arg {String} [event.description] The description of the event - * @arg {Number} [event.entityType] The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event - * @arg {String} eventID The event ID - * @returns {Promise} + * @arg {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event + * @arg {Number} [event.status] The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event + * @returns {Promise} */ - editGuildEvent(event, eventID) { - return this.requestHandler.request("POST", Endpoints.GUILD_EVENT(eventID), true, { + editGuildEvent(guildID, eventID, event) { + return this.requestHandler.request("PATCH", Endpoints.GUILD_SCHEDULED_EVENT(guildID, eventID), true, { channel_id: event.channelID, + entity_metadata: { + speaker_ids: event.entityMetadata.speakerIDs, + location: event.entityMetadata.location + }, name: event.name, privacy_level: event.privacyLevel, scheduled_start_time: event.scheduledStartTime, + scheduled_end_time: event.scheduledEndTime, description: event.description, - entity_type: event.entityType - }).then((data) => new GuildEvent(data, this)); + entity_type: event.entityType, + status: event.status + }); } /** * Edit a guild integration @@ -2729,15 +2737,16 @@ class Client extends EventEmitter { /** * Get a guild scheduled event data via the REST API. REST mode is required to use this endpoint. + * @arg {String} guildID The guild id to get the event of * @arg {String} eventID The id of the event - * @returns {Promise} + * @returns {Promise} */ - getRESTGuildEvent(eventID) { + getRESTGuildEvent(guildID, eventID) { if(!this.options.restMode) { return Promise.reject(new Error("Eris REST mode is not enabled")); } - return this.requestHandler.request("GET", Endpoints.GUILD_EVENT(eventID), true).then((data) => new GuildEvent(data, this)); + return this.requestHandler.request("GET", Endpoints.GUILD_SCHEDULED_EVENT(guildID, eventID), true).then((data) => new GuildEvent(data, this)); } /** * Get a guild's members via the REST API. REST mode is required to use this endpoint. @@ -3070,6 +3079,10 @@ class Client extends EventEmitter { }).then((events) => events.map((event) => new GuildEvent(event, this))); } + listGuildEventUsers(guildID, eventID) { + return this.requestHandler.request("GET", Endpoints.GUILD_SCHEDULED_EVENT_USERS(guildID, eventID)); + } + /** * Pin a message * @arg {String} channelID The ID of the channel diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 551e041b1..b66df28a9 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2365,7 +2365,7 @@ class Shard extends EventEmitter { * @prop {Number} oldEvent.privacyLevel The privacy level of the event * @prop {Date} oldEvent.scheduledStartTime The time the event will start * @prop {String} oldEvent.description The description of the event - * @prop {Number} oldEvent.entityType The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event + * @prop {Number} oldEvent.entityType The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event */ this.emit("guildScheduledEventUpdate", event, oldEvent); break; diff --git a/lib/rest/Endpoints.js b/lib/rest/Endpoints.js index f4c4abd20..0399173b3 100644 --- a/lib/rest/Endpoints.js +++ b/lib/rest/Endpoints.js @@ -62,9 +62,9 @@ module.exports.GUILD_PREVIEW = (guildID) module.exports.GUILD_PRUNE = (guildID) => `/guilds/${guildID}/prune`; module.exports.GUILD_ROLE = (guildID, roleID) => `/guilds/${guildID}/roles/${roleID}`; module.exports.GUILD_ROLES = (guildID) => `/guilds/${guildID}/roles`; -module.exports.GUILD_SCHEDULED_EVENT = (guildID, scheduledEventID) => `/guilds/${guildID}/scheduled-events/${scheduledEventID}/guild-scheduled-event-object}`; +module.exports.GUILD_SCHEDULED_EVENT = (guildID, scheduledEventID) => `/guilds/${guildID}/scheduled-events/${scheduledEventID}`; module.exports.GUILD_SCHEDULED_EVENTS = (guildID) => `/guilds/${guildID}/scheduled-events`; -module.exports.GUILD_SCHEDULED_EVENT_USERS = (guildID, scheduledEventID) => `/guilds/${guildID}/scheduled-events/${scheduledEventID}/guild-scheduled-event-object}/users`; +module.exports.GUILD_SCHEDULED_EVENT_USERS = (guildID, scheduledEventID) => `/guilds/${guildID}/scheduled-events/${scheduledEventID}/users`; module.exports.GUILD_STICKER = (guildID, stickerID) => `/guilds/${guildID}/stickers/${stickerID}`; module.exports.GUILD_STICKERS = (guildID) => `/guilds/${guildID}/stickers`; module.exports.GUILD_TEMPLATE = (code) => `/guilds/templates/${code}`; diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 3b1c7713d..b69fe2d62 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -444,7 +444,7 @@ class Guild extends Base { * @arg {Date} [event.scheduledStartTime] The time the event will start * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end * @arg {String} [event.description] The description of the event - * @arg {Number} [event.entityType] The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event + * @arg {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event * @returns {Promise} */ createEvent(event) { @@ -977,6 +977,14 @@ class Guild extends Base { return this._client.getRESTGuildEmojis.call(this._client, this.id); } + /** + * Get a guild scheduled event data via the REST API. REST mode is required to use this endpoint. + * @arg {String} eventID The id of the event + * @returns {Promise} + */ + getRESTEvent(eventID) { + return this._client.getRESTGuildEvent.call(this._client, this.id, eventID); + } /** * Get a guild's members via the REST API. REST mode is required to use this endpoint. * @arg {String} memberID The ID of the member @@ -1006,6 +1014,9 @@ class Guild extends Base { return this._client.getRESTGuildRoles.call(this._client, this.id); } + + + /** * Get a guild sticker via the REST API. REST mode is required to use this endpoint. * @arg {String} stickerID The ID of the sticker @@ -1105,14 +1116,23 @@ class Guild extends Base { } /** - * List all scheduled events for this guild. - * @arg {Boolean} withUserCount Include number of users subscribed to each event + * List all scheduled events for this guild + * @arg {Boolean} withUserCount Whether to include number of users subscribed to each event * @returns {Promise>} */ listEvents(withUserCount) { return this._client.listGuildEvents.call(this._client, this.id, withUserCount); } + /** + * List all users that subscribed to the given event + * @arg {String} eventID The event id + * @returns {} + */ + listEventUsers(eventID) { + return this._client.listGuildEventUsers.call(this._client, this.id, eventID); + } + /** * Get the guild permissions of a member * @arg {String | Member | Object} memberID The ID of the member or a Member object diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index bc9050086..733847f69 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -13,8 +13,8 @@ const User = require("./User"); * @prop {Number} scheduledStartTime The time the event will start * @prop {Number} scheduledEndTime The time the event will end, or null if the event does not have a scheduled time to end * @prop {Number} privacyLevel Event privacy level -* @prop {Number} status The [scheduled status](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-status) of the event -* @prop {Number} entityType The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event +* @prop {Number} status The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event +* @prop {Number} entityType The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event * @prop {String} entityID Entity id * @prop {Object} entityMetadata Metadata for the event * @prop {Array} entityMetadata.speakerIDs The speakers of the stage channel @@ -78,22 +78,35 @@ class GuildEvent extends Base { * @returns {Promise} */ delete() { - return this._client.deleteGuildEvent.call(this._client, this.id); + return this._client.deleteGuildEvent.call(this._client, this.guildID, this.id); } /** * Edit this scheduled event - * @arg {Object} event The event to be edited + * @arg {Object} event The new scheuled guild event object * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel ID of the event + * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event + * @arg {Array} [event.entityMetadata.speakerIDs] The speakers of the stage channel + * @arg {String} [event.entityMetadata.location] Location of the event * @arg {String} [event.privacyLevel] The privacy level of the event * @arg {Date} [event.scheduledStartTime] The time the event will start + * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end * @arg {String} [event.description] The description of the event - * @arg {Number} [event.entityType] The [scheduled entity type](https://discord.com/developers/docs/resources/guild_event/guild-event-object-guild-scheduled-event-entity-types) of the event - * @returns {Promise} + * @arg {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event + * @arg {Number} [event.status] The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event + * @returns {Promise} */ edit(event) { - return this._client.editGuildEvent.call(this._client, event, this.id); + return this._client.editGuildEvent.call(this._client, this.guildID, this.id, event); + } + + /** + * List all users that subscribed to this event + * @returns {} + */ + listUsers() { + return this._client.listGuildEventUsers.call(this._client, this.guildID, this.id); } toJSON(props = []) { From d828fe689f918b51e704d1a423c1271401b9d578 Mon Sep 17 00:00:00 2001 From: reydner alves Date: Thu, 2 Dec 2021 15:41:16 -0300 Subject: [PATCH 58/70] feat: add guild scheduled events intent --- index.d.ts | 5 +++-- lib/Constants.js | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index e7c3b027d..e28800008 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1692,9 +1692,10 @@ declare namespace Eris { directMessages: 4096; directMessageReactions: 8192; directMessageTyping: 16384; - allNonPrivileged: 32509; + guildScheduledEvents: 65536; + allNonPrivileged: 98045; allPrivileged: 258; - all: 32767; + all: 98303; }; InteractionResponseTypes: { PONG: 1; diff --git a/lib/Constants.js b/lib/Constants.js index 7375db4c4..846730568 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -233,7 +233,9 @@ const Intents = { guildMessageTyping: 1 << 11, directMessages: 1 << 12, directMessageReactions: 1 << 13, - directMessageTyping: 1 << 14 + directMessageTyping: 1 << 14, + + guildScheduledEvents: 1 << 16 }; Intents.allNonPrivileged = Intents.guilds | Intents.guildBans @@ -247,7 +249,8 @@ Intents.allNonPrivileged = Intents.guilds | Intents.guildMessageTyping | Intents.directMessages | Intents.directMessageReactions - | Intents.directMessageTyping; + | Intents.directMessageTyping + | Intents.guildScheduledEvents; Intents.allPrivileged = Intents.guildMembers | Intents.guildPresences; Intents.all = Intents.allNonPrivileged | Intents.allPrivileged; From 47c590578c6fb350d55d27994ca37d9c2de90e5a Mon Sep 17 00:00:00 2001 From: reydner alves Date: Thu, 2 Dec 2021 15:57:01 -0300 Subject: [PATCH 59/70] feat: remove speakerIDs --- index.d.ts | 1 - lib/Client.js | 4 ---- lib/structures/Guild.js | 1 - lib/structures/GuildEvent.js | 4 +--- 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/index.d.ts b/index.d.ts index e28800008..036a1449f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1450,7 +1450,6 @@ declare namespace Eris { user: PartialUser; } interface GuildEventMetadata { - speakerIDs?: string[]; location?: string; } interface GuildEventOptions { diff --git a/lib/Client.js b/lib/Client.js index 35193e3b6..8f35c01b1 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -660,7 +660,6 @@ class Client extends EventEmitter { * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel ID of the event * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event - * @arg {Array} [event.entityMetadata.speakerIDs] The speakers of the stage channel * @arg {String} [event.entityMetadata.location] Location of the event * @arg {String} [event.privacyLevel] The privacy level of the event * @arg {Date} [event.scheduledStartTime] The time the event will start @@ -674,7 +673,6 @@ class Client extends EventEmitter { name: event.name, channel_id: event.channelID, entity_metadata: { - speaker_ids: event.entityMetadata.speakerIDs, location: event.entityMetadata.location }, privacy_level: event.privacyLevel, @@ -1516,7 +1514,6 @@ class Client extends EventEmitter { * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel ID of the event * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event - * @arg {Array} [event.entityMetadata.speakerIDs] The speakers of the stage channel * @arg {String} [event.entityMetadata.location] Location of the event * @arg {String} [event.privacyLevel] The privacy level of the event * @arg {Date} [event.scheduledStartTime] The time the event will start @@ -1530,7 +1527,6 @@ class Client extends EventEmitter { return this.requestHandler.request("PATCH", Endpoints.GUILD_SCHEDULED_EVENT(guildID, eventID), true, { channel_id: event.channelID, entity_metadata: { - speaker_ids: event.entityMetadata.speakerIDs, location: event.entityMetadata.location }, name: event.name, diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 2c90be29b..010424df7 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -438,7 +438,6 @@ class Guild extends Base { * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel ID of the event * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event - * @arg {Array} [event.entityMetadata.speakerIDs] The speakers of the stage channel * @arg {String} [event.entityMetadata.location] Location of the event * @arg {String} [event.privacyLevel] The privacy level of the event * @arg {Date} [event.scheduledStartTime] The time the event will start diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildEvent.js index 733847f69..f4bc2d419 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildEvent.js @@ -17,7 +17,6 @@ const User = require("./User"); * @prop {Number} entityType The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event * @prop {String} entityID Entity id * @prop {Object} entityMetadata Metadata for the event -* @prop {Array} entityMetadata.speakerIDs The speakers of the stage channel * @prop {String} entityMetadata.location Location of the event * @prop {User} creator The user that created the scheduled event * @prop {Number?} userCount Users subscribed to the event @@ -63,7 +62,7 @@ class GuildEvent extends Base { this.entityID = data.entity_id; } if(data.entity_metadata !== undefined) { - this.entityMetadata = {speakerIDs: data.speaker_ids, location: data.location}; + this.entityMetadata = {location: data.location}; } if(data.creator !== undefined) { this.creator = new User(data.creator ,this._client); @@ -87,7 +86,6 @@ class GuildEvent extends Base { * @arg {String} [event.name] The name of the event * @arg {String} [event.channelID] The channel ID of the event * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event - * @arg {Array} [event.entityMetadata.speakerIDs] The speakers of the stage channel * @arg {String} [event.entityMetadata.location] Location of the event * @arg {String} [event.privacyLevel] The privacy level of the event * @arg {Date} [event.scheduledStartTime] The time the event will start From c8278abecdee091450a1c804c9fcedfe678aca07 Mon Sep 17 00:00:00 2001 From: reydner alves Date: Thu, 2 Dec 2021 16:05:00 -0300 Subject: [PATCH 60/70] feat: document guild method --- index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/index.d.ts b/index.d.ts index 036a1449f..5aeec8c3d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2791,6 +2791,7 @@ declare namespace Eris { getRESTChannels(): Promise; getRESTEmoji(emojiID: string): Promise; getRESTEmojis(): Promise; + getRESTEvent(eventID: string): Promise; getRESTMember(memberID: string): Promise; getRESTMembers(options?: GetRESTGuildMembersOptions): Promise; /** @deprecated */ From fd0a2eea8129129b4521004b0e098a8a60208ce3 Mon Sep 17 00:00:00 2001 From: Bsian Date: Wed, 13 Apr 2022 02:52:04 +0100 Subject: [PATCH 61/70] [INCOMPLETE] Fix PR --- esm.mjs | 2 +- index.d.ts | 95 ++++---- index.js | 2 +- lib/Client.js | 218 ++++++++++-------- lib/Constants.js | 4 +- lib/gateway/Shard.js | 74 +++--- lib/rest/Endpoints.js | 3 +- lib/rest/RequestHandler.js | 1 - lib/structures/Guild.js | 64 ++--- .../{GuildEvent.js => GuildScheduledEvent.js} | 83 ++++--- lib/structures/NewsChannel.js | 1 + lib/structures/PrivateChannel.js | 1 - lib/voice/SharedStream.js | 1 - 13 files changed, 286 insertions(+), 263 deletions(-) rename lib/structures/{GuildEvent.js => GuildScheduledEvent.js} (57%) diff --git a/esm.mjs b/esm.mjs index 015b711d9..7248841b1 100644 --- a/esm.mjs +++ b/esm.mjs @@ -26,6 +26,7 @@ export const { GuildChannel, GuildIntegration, GuildPreview, + GuildScheduledEvent, GuildTemplate, Interaction, Invite, @@ -59,5 +60,4 @@ export const { VoiceConnection, VoiceConnectionManager, VoiceState, - GuildEvent } = Eris; diff --git a/index.d.ts b/index.d.ts index 4134cfb03..e4bd4ecd2 100644 --- a/index.d.ts +++ b/index.d.ts @@ -86,9 +86,9 @@ declare namespace Eris { // Guild type DefaultNotifications = Constants["DefaultMessageNotificationLevels"][keyof Constants["DefaultMessageNotificationLevels"]]; type ExplicitContentFilter = Constants["ExplicitContentFilterLevels"][keyof Constants["ExplicitContentFilterLevels"]]; - type GuildEventEntityTypes = Constants["GuildEventEntityTypes"][keyof Constants["GuildEventEntityTypes"]]; - type GuildEventPrivacyLevel = Constants["GuildEventPrivacyLevel"][keyof Constants["GuildEventPrivacyLevel"]]; - type GuildEventStatus = Constants["GuildEventStatus"][keyof Constants["GuildEventStatus"]]; + type GuildScheduledEventEntityTypes = Constants["GuildScheduledEventEntityTypes"][keyof Constants["GuildScheduledEventEntityTypes"]]; + type GuildScheduledEventPrivacyLevel = Constants["GuildScheduledEventPrivacyLevel"][keyof Constants["GuildScheduledEventPrivacyLevel"]]; + type GuildScheduledEventStatus = Constants["GuildScheduledEventStatus"][keyof Constants["GuildScheduledEventStatus"]]; type GuildFeatures = Constants["GuildFeatures"][number]; type NSFWLevel = Constants["GuildNSFWLevels"][keyof Constants["GuildNSFWLevels"]]; type PossiblyUncachedGuild = Guild | Uncached; @@ -755,11 +755,11 @@ declare namespace Eris { voiceStateUpdate: [member: Member, oldState: OldVoiceState]; warn: [message: string, id?: number]; webhooksUpdate: [data: WebhookData]; - guildScheduledEventCreate: [event: GuildEvent]; - guildScheduledEventUpdate: [event: GuildEvent, oldEvent: GuildEventOptions | null]; - guildScheduledEventDelete: [event: GuildEvent]; - guildScheduledEventUserAdd: [event: GuildEvent | string, user: User | string]; - guildScheduledEventUserRemove: [event: GuildEvent | string, user: User | string]; + guildScheduledEventCreate: [event: GuildScheduledEvent]; + guildScheduledEventUpdate: [event: GuildScheduledEvent, oldEvent: GuildScheduledEventOptions | null]; + guildScheduledEventDelete: [event: GuildScheduledEvent]; + guildScheduledEventUserAdd: [event: GuildScheduledEvent | string, user: User | string]; + guildScheduledEventUserRemove: [event: GuildScheduledEvent | string, user: User | string]; } interface ClientEvents extends EventListeners { shardDisconnect: [err: Error | undefined, id: number]; @@ -1453,21 +1453,21 @@ declare namespace Eris { team_id: string; user: PartialUser; } - interface GuildEventMetadata { + interface GuildScheduledEventMetadata { location?: string; } - interface GuildEventOptions { + interface GuildScheduledEventOptions { name: string; channelID: string; - entityMetadata: GuildEventMetadata; - privacyLevel: GuildEventPrivacyLevel; + entityMetadata: GuildScheduledEventMetadata; + privacyLevel: GuildScheduledEventPrivacyLevel; scheduledStartTime: Date; scheduledEndTime: Date; description: string; - entityType: GuildEventEntityTypes; + entityType: GuildScheduledEventEntityTypes; } - interface GuildEventEditOptions extends GuildEventOptions { - status: GuildEventStatus; + interface GuildScheduledEventEditOptions extends GuildScheduledEventOptions { + status: GuildScheduledEventStatus; } interface Constants { GATEWAY_VERSION: 9; @@ -1946,19 +1946,19 @@ declare namespace Eris { /** @deprecated */ DISCONNECT: 13; }; - GuildEventStatus: { + GuildScheduledEventStatus: { SCHEDULED: 1; ACTIVE: 2; COMPLETED: 3; CANCELED: 4; }; - GuildEventEntityTypes: { + GuildScheduledEventEntityTypes: { NONE: 0; STAGE_INSTANCE: 1; VOICE: 2; LOCATION: 3; }; - GuildEventPrivacyLevel: { + GuildScheduledEventPrivacyLevel: { PUBLIC: 1; GUILD_ONLY: 2; }; @@ -2274,7 +2274,7 @@ declare namespace Eris { createGuild(name: string, options?: CreateGuildOptions): Promise; createGuildCommand(guildID: string, command: ApplicationCommandStructure): Promise; createGuildEmoji(guildID: string, options: EmojiOptions, reason?: string): Promise; - createGuildEvent(guildID: string, event: GuildEventOptions): Promise; + createGuildScheduledEvent(guildID: string, event: GuildScheduledEventOptions): Promise; createGuildFromTemplate(code: string, name: string, icon?: string): Promise; createGuildSticker(guildID: string, options: CreateStickerOptions, reason?: string): Promise; createGuildTemplate(guildID: string, name: string, description?: string | null): Promise; @@ -2292,7 +2292,7 @@ declare namespace Eris { deleteGuildCommand(guildID: string, commandID: string): Promise; deleteGuildDiscoverySubcategory(guildID: string, categoryID: string, reason?: string): Promise; deleteGuildEmoji(guildID: string, emojiID: string, reason?: string): Promise; - deleteGuildEvent(guildID: string, eventID: string): Promise; + deleteGuildScheduledEvent(guildID: string, eventID: string): Promise; deleteGuildIntegration(guildID: string, integrationID: string): Promise; deleteGuildSticker(guildID: string, stickerID: string, reason?: string): Promise; deleteGuildTemplate(guildID: string, code: string): Promise; @@ -2334,7 +2334,7 @@ declare namespace Eris { options: { name?: string; roles?: string[] }, reason?: string ): Promise; - editGuildEvent(event: GuildEventEditOptions, eventID: string): Promise; + editGuildScheduledEvent(event: GuildScheduledEventEditOptions, eventID: string): Promise; editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise; editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise; editGuildSticker(guildID: string, stickerID: string, options?: EditStickerOptions, reason?: string): Promise; @@ -2438,7 +2438,7 @@ declare namespace Eris { getRESTGuildChannels(guildID: string): Promise; getRESTGuildEmoji(guildID: string, emojiID: string): Promise; getRESTGuildEmojis(guildID: string): Promise; - getRESTGuildEvent(guildID: string, eventID: string): Promise; + getRESTGuildScheduledEvent(guildID: string, eventID: string): Promise; getRESTGuildMember(guildID: string, memberID: string): Promise; getRESTGuildMembers(guildID: string, options?: GetRESTGuildMembersOptions): Promise; /** @deprecated */ @@ -2498,8 +2498,8 @@ declare namespace Eris { leaveGuild(guildID: string): Promise; leaveThread(channelID: string, userID?: string): Promise; leaveVoiceChannel(channelID: string): void; - listGuildEvents(guildID: string, withUserCount: boolean): Promise>; - listGuildEventUsers(guildID: string, eventID: string): void; + listGuildScheduledEvents(guildID: string, withUserCount: boolean): Promise>; + listGuildScheduledEventUsers(guildID: string, eventID: string): void; off(event: K, listener: (...args: ClientEvents[K]) => void): this; off(event: string, listener: (...args: any[]) => void): this; once(event: K, listener: (...args: ClientEvents[K]) => void): this; @@ -2671,7 +2671,7 @@ declare namespace Eris { discoverySplashURL: string | null; emojiCount?: number; emojis: Emoji[]; - events: Collection; + events: Collection; explicitContentFilter: ExplicitContentFilter; features: GuildFeatures[]; icon: string | null; @@ -2743,7 +2743,7 @@ declare namespace Eris { createChannel(name: string, type?: number, reason?: string, options?: CreateChannelOptions | string): Promise; createCommand(command: ApplicationCommandStructure): Promise; createEmoji(options: { image: string; name: string; roles?: string[] }, reason?: string): Promise; - createEvent(event: GuildEventOptions): Promise; + createScheduledEvent(event: GuildScheduledEventOptions): Promise; createRole(options: RoleOptions | Role, reason?: string): Promise; createSticker(options: CreateStickerOptions, reason?: string): Promise; createTemplate(name: string, description?: string | null): Promise; @@ -2795,7 +2795,7 @@ declare namespace Eris { getRESTChannels(): Promise; getRESTEmoji(emojiID: string): Promise; getRESTEmojis(): Promise; - getRESTEvent(eventID: string): Promise; + getRESTEvent(eventID: string): Promise; getRESTMember(memberID: string): Promise; getRESTMembers(options?: GetRESTGuildMembersOptions): Promise; /** @deprecated */ @@ -2813,7 +2813,7 @@ declare namespace Eris { kickMember(userID: string, reason?: string): Promise; leave(): Promise; leaveVoiceChannel(): void; - listEvents(withUserCount: boolean): Promise>; + listEvents(withUserCount: boolean): Promise>; listEventUsers(eventID: string): void; permissionsOf(memberID: string | Member | MemberRoles): Permission; pruneMembers(options?: PruneMemberOptions): Promise; @@ -2868,6 +2868,25 @@ declare namespace Eris { permissionsOf(memberID: string | Member | MemberRoles): Permission; } + export class GuildScheduledEvent extends Base { + channelID: string; + description?: string; + entityID: string; + entityMetadata: GuildScheduledEventMetadata; + entityType: GuildScheduledEventEntityTypes; + guildID: string; + id: string; + name: string; + privacyLevel: GuildScheduledEventPrivacyLevel; + scheduledEndTime: number; + scheduledStartTime: number; + status: GuildScheduledEventStatus; + creator?: User; + userCount?: number; + delete(): Promise; + edit(event: GuildScheduledEventEditOptions): Promise; + listUsers(): void; + } export class GuildIntegration extends Base { account: { id: string; name: string }; @@ -3706,26 +3725,6 @@ declare namespace Eris { suppress: boolean; constructor(data: BaseData); } - - export class GuildEvent extends Base { - channelID: string; - description?: string; - entityID: string; - entityMetadata: GuildEventMetadata; - entityType: GuildEventEntityTypes; - guildID: string; - id: string; - name: string; - privacyLevel: GuildEventPrivacyLevel; - scheduledEndTime: number; - scheduledStartTime: number; - status: GuildEventStatus; - creator?: User; - userCount?: number; - delete(): Promise; - edit(event: GuildEventEditOptions): Promise; - listUsers(): void; - } } export = Eris; diff --git a/index.js b/index.js index 346795d9e..ca2b3a1df 100644 --- a/index.js +++ b/index.js @@ -27,6 +27,7 @@ Eris.Guild = require("./lib/structures/Guild"); Eris.GuildChannel = require("./lib/structures/GuildChannel"); Eris.GuildIntegration = require("./lib/structures/GuildIntegration"); Eris.GuildPreview = require("./lib/structures/GuildPreview"); +Eris.GuildScheduledEvent = require("./lib/structures/GuildScheduledEvent"); Eris.GuildTemplate = require("./lib/structures/GuildTemplate"); Eris.Interaction = require("./lib/structures/Interaction"); Eris.Invite = require("./lib/structures/Invite"); @@ -60,6 +61,5 @@ Eris.VoiceChannel = require("./lib/structures/VoiceChannel"); Eris.VoiceConnection = require("./lib/voice/VoiceConnection"); Eris.VoiceConnectionManager = require("./lib/voice/VoiceConnectionManager"); Eris.VoiceState = require("./lib/structures/VoiceState"); -Eris.GuildEvent = require("./lib/structures/GuildEvent"); module.exports = Eris; diff --git a/lib/Client.js b/lib/Client.js index 1aff19455..05913b790 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -12,7 +12,7 @@ const GuildAuditLogEntry = require("./structures/GuildAuditLogEntry"); const GuildIntegration = require("./structures/GuildIntegration"); const GuildPreview = require("./structures/GuildPreview"); const GuildTemplate = require("./structures/GuildTemplate"); -const GuildEvent = require("./structures/GuildEvent"); +const GuildScheduledEvent = require("./structures/GuildScheduledEvent"); const Invite = require("./structures/Invite"); const Member = require("./structures/Member"); const Message = require("./structures/Message"); @@ -215,7 +215,6 @@ class Client extends EventEmitter { this.privateChannelMap = {}; this.privateChannels = new Collection(PrivateChannel); this.guildShardMap = {}; - this.guildEventMap = {}; this.unavailableGuilds = new Collection(UnavailableGuild); this.relationships = new Collection(Relationship); this.users = new Collection(User); @@ -349,7 +348,7 @@ class Client extends EventEmitter { /** * Edits command permissions for a multiple commands in a guild. * Note: You can only add up to 10 permission overwrites for a command. - * @arg {String} guildID The guild id + * @arg {String} guildID The guild ID * @arg {Array} permissions An array of [partial guild command permissions](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) * @returns {Promise>} Returns an array of [GuildApplicationCommandPermissions](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) objects. */ @@ -657,36 +656,6 @@ class Client extends EventEmitter { return this.requestHandler.request("POST", Endpoints.GUILD_EMOJIS(guildID), true, options); } - /** - * Create a scheduled guild event - * @arg {String} guildID The guild ID where the event will be created - * @arg {Object} event The event to be created - * @arg {String} [event.name] The name of the event - * @arg {String} [event.channelID] The channel ID of the event - * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event - * @arg {String} [event.entityMetadata.location] Location of the event - * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {Date} [event.scheduledStartTime] The time the event will start - * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end - * @arg {String} [event.description] The description of the event - * @arg {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event - * @returns {Promise} - */ - createGuildEvent(guildID, event) { - return this.requestHandler.request("POST", Endpoints.GUILD_SCHEDULED_EVENTS(guildID), true, { - name: event.name, - channel_id: event.channelID, - entity_metadata: { - location: event.entityMetadata.location - }, - privacy_level: event.privacyLevel, - scheduled_start_time: event.scheduledStartTime, - scheduled_end_time: event.scheduledEndTime, - description: event.description, - entity_type: event.entityType - }).then((data) => new GuildEvent(data, this)); - } - /** * Create a guild based on a template. This can only be used with bots in less than 10 guilds * @arg {String} code The template code @@ -700,6 +669,37 @@ class Client extends EventEmitter { icon }).then((guild) => new Guild(guild, this)); } + + /** + * Create a guild scheduled event + * @arg {String} guildID The guild ID where the event will be created + * @arg {Object} event The event to be created + * @arg {String} [event.channelID] The channel ID of the event. This is optional if `entityType` is `3` (external) + * @arg {String} [event.description] The description of the event + * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if `entityType` is `3` (external) + * @arg {String} [event.entityMetadata.location] Location of the event + * @arg {Number} event.entityType The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event + * @arg {String} [event.image] Base 64 encoded image for the scheduled event + * @arg {String} event.name The name of the event + * @arg {String} event.privacyLevel The privacy level of the event + * @arg {Date} [event.scheduledEndTime] The time when the event is scheduled to end. This is required if `entityType` is `3` (external) + * @arg {Date} event.scheduledStartTime The time the event will start + * @returns {Promise} + */ + createGuildScheduledEvent(guildID, event) { + return this.requestHandler.request("POST", Endpoints.GUILD_SCHEDULED_EVENTS(guildID), true, { + channel_id: event.channelID, + description: event.description, + entity_metadata: event.entityMetadata, + entity_type: event.entityType, + image: event.image, + name: event.name, + privacy_level: event.privacyLevel, + scheduled_end_time: event.scheduledEndTime, + scheduled_start_time: event.scheduledStartTime + }).then((data) => new GuildScheduledEvent(data, this)); + } + /** * Create a guild sticker * @arg {Object} options Sticker options @@ -720,6 +720,7 @@ class Client extends EventEmitter { reason: reason }, options.file); } + /** * Create a template for a guild * @arg {String} guildID The ID of the guild @@ -733,6 +734,7 @@ class Client extends EventEmitter { description }).then((template) => new GuildTemplate(template, this)); } + /** * Respond to the interaction with a message * Note: Use webhooks if you have already responded with an interaction response. @@ -782,6 +784,7 @@ class Client extends EventEmitter { } return this.requestHandler.request("POST", Endpoints.INTERACTION_RESPOND(interactionID, interactionToken), true, options, file, "/interactions/:id/:token/callback"); } + /** * Create a message in a channel * Note: If you want to DM someone, the user ID is **not** the DM channel ID. use Client.getDMChannel() to get the DM channel for a user @@ -866,6 +869,7 @@ class Client extends EventEmitter { } return this.requestHandler.request("POST", Endpoints.CHANNEL_MESSAGES(channelID), true, content, file).then((message) => new Message(message, this)); } + /** * Create a guild role * @arg {String} guildID The ID of the guild to create the role in @@ -902,6 +906,7 @@ class Client extends EventEmitter { } }); } + /** * Create a stage instance * @arg {String} channelID The ID of the stage channel to create the instance in @@ -917,6 +922,7 @@ class Client extends EventEmitter { topic: options.topic }).then((instance) => new StageInstance(instance, this)); } + /** * Create a thread with an existing message * @arg {String} channelID The ID of the channel @@ -932,6 +938,7 @@ class Client extends EventEmitter { auto_archive_duration: options.autoArchiveDuration }).then((channel) => Channel.from(channel, this)); } + /** * Create a thread without an existing message * @arg {String} channelID The ID of the channel @@ -950,6 +957,7 @@ class Client extends EventEmitter { type: options.type }).then((channel) => Channel.from(channel, this)); } + /** * Crosspost (publish) a message to subscribed channels * @arg {String} channelID The ID of the NewsChannel @@ -1008,7 +1016,7 @@ class Client extends EventEmitter { /** * Delete a guild application command - * @arg {String} guildID The guild id + * @arg {String} guildID The guild ID * @arg {String} commandID The command id * @returns {Promise} */ @@ -1046,15 +1054,6 @@ class Client extends EventEmitter { }); } - /** - * Delete a guild scheduled event - * @arg {String} guildID The guild id of where the event belongs to - * @arg {String} eventID The event id - * @returns {Promise} - */ - deleteGuildEvent(guildID, eventID) { - return this.requestHandler.request("DELETE", Endpoints.GUILD_SCHEDULED_EVENT(guildID, eventID), true); - } /** * Delete a guild integration * @arg {String} guildID The ID of the guild @@ -1065,6 +1064,16 @@ class Client extends EventEmitter { return this.requestHandler.request("DELETE", Endpoints.GUILD_INTEGRATION(guildID, integrationID), true); } + /** + * Delete a guild scheduled event + * @arg {String} guildID The ID of the guild + * @arg {String} eventID The ID of the event + * @returns {Promise} + */ + deleteGuildScheduledEvent(guildID, eventID) { + return this.requestHandler.request("DELETE", Endpoints.GUILD_SCHEDULED_EVENT(guildID, eventID), true); + } + /** * Delete a guild sticker * @arg {String} guildID The ID of the guild @@ -1304,6 +1313,7 @@ class Client extends EventEmitter { reason: reason }).then((channel) => Channel.from(channel, this)); } + /** * Create a channel permission overwrite * @arg {String} channelID The ID of channel @@ -1325,6 +1335,7 @@ class Client extends EventEmitter { reason }); } + /** * Edit a guild channel's position. Note that channel position numbers are lowest on top and highest at the bottom. * @arg {String} channelID The ID of the channel @@ -1363,6 +1374,7 @@ class Client extends EventEmitter { parent_id: options.parentID }))); } + /** * Edit a global application command * @arg {String} commandID The command id @@ -1388,10 +1400,11 @@ class Client extends EventEmitter { command.default_permission = command.defaultPermission; return this.requestHandler.request("PATCH", Endpoints.COMMAND(this.application.id, commandID), true, command); } + /** * Edits command permissions for a specific command in a guild. * Note: You can only add up to 10 permission overwrites for a command. - * @arg {String} guildID The guild id + * @arg {String} guildID The guild ID * @arg {String} commandID The command id * @arg {Array} permissions An array of [permissions objects](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-structure) * @returns {Promise} Resolves with a [GuildApplicationCommandPermissions](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) object. @@ -1457,7 +1470,7 @@ class Client extends EventEmitter { /** * Edit a guild application command - * @arg {String} guildID The guild id + * @arg {String} guildID The guild ID * @arg {Object} command A command object * @arg {String} command.name The command name * @arg {String} [command.description] The command description (Slash Commands Only) @@ -1514,38 +1527,7 @@ class Client extends EventEmitter { options.reason = reason; return this.requestHandler.request("PATCH", Endpoints.GUILD_EMOJI(guildID, emojiID), true, options); } - /** - * Edit a scheduled guild event - * @arg {String} guildID The guild ID where the event will be edited - * @arg {String} eventID The id of the scheduled guild event to be edited - * @arg {Object} event The new scheuled guild event object - * @arg {String} [event.name] The name of the event - * @arg {String} [event.channelID] The channel ID of the event - * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event - * @arg {String} [event.entityMetadata.location] Location of the event - * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {Date} [event.scheduledStartTime] The time the event will start - * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end - * @arg {String} [event.description] The description of the event - * @arg {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event - * @arg {Number} [event.status] The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event - * @returns {Promise} - */ - editGuildEvent(guildID, eventID, event) { - return this.requestHandler.request("PATCH", Endpoints.GUILD_SCHEDULED_EVENT(guildID, eventID), true, { - channel_id: event.channelID, - entity_metadata: { - location: event.entityMetadata.location - }, - name: event.name, - privacy_level: event.privacyLevel, - scheduled_start_time: event.scheduledStartTime, - scheduled_end_time: event.scheduledEndTime, - description: event.description, - entity_type: event.entityType, - status: event.status - }); - } + /** * Edit a guild integration * @arg {String} guildID The ID of the guild @@ -1590,6 +1572,41 @@ class Client extends EventEmitter { }).then((member) => new Member(member, this.guilds.get(guildID), this)); } + /** + * Edit a guild scheduled event + * @arg {String} guildID The guild ID where the event will be edited + * @arg {String} eventID The id of the guild scheduled event to be edited + * @arg {Object} event The new guild scheduled event object + * @arg {String} [event.channelID] The channel ID of the event. If updating `entityType` to `3` (external), this **must** be set to `null` + * @arg {String} [event.description] The description of the event + * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if updating `entityType` to `3` (external) + * @arg {String} [event.entityMetadata.location] Location of the event. This is required if updating `entityType` to `3` (external) + * @arg {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event + * @arg {String} [event.image] Base 64 encoded image for the event + * @arg {String} [event.name] The name of the event + * @arg {String} [event.privacyLevel] The privacy level of the event + * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end. This is required if updating `entityType` to `3` (external) + * @arg {Date} [event.scheduledStartTime] The time the event will start + * @arg {Number} [event.status] The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event + * @arg {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ + editGuildScheduledEvent(guildID, eventID, event, reason) { + return this.requestHandler.request("PATCH", Endpoints.GUILD_SCHEDULED_EVENT(guildID, eventID), true, { + channel_id: event.channelID, + description: event.description, + entity_metadata: event.entityMetadata, + entity_type: event.entityType, + image: event.image, + name: event.name, + privacy_level: event.privacyLevel, + scheduled_end_time: event.scheduledEndTime, + scheduled_start_time: event.scheduledStartTime, + status: event.status, + reason: reason + }); + } + /** * Edit a guild sticker * @arg {String} stickerID The ID of the sticker @@ -1629,6 +1646,7 @@ class Client extends EventEmitter { code }); } + /** * Update a user's voice state - See [caveats](https://discord.com/developers/docs/resources/guild#update-others-voice-state-caveats) * @arg {String} guildID The ID of the guild @@ -1951,9 +1969,6 @@ class Client extends EventEmitter { }); } - - - /** * Edit a webhook * @arg {String} webhookID The ID of the webhook @@ -2254,7 +2269,7 @@ class Client extends EventEmitter { /** * Get the a guild's application command permissions - * @arg {String} guildID The guild id + * @arg {String} guildID The guild ID * @arg {String} commandID The command id * @returns {Promise} Resolves with a guild application command permissions object. */ @@ -2404,7 +2419,7 @@ class Client extends EventEmitter { /** * Get a guild application command - * @arg {String} guildID The guild id + * @arg {String} guildID The guild ID * @arg {String} commandID The command id * @returns {Promise} Resolves with an command object. */ @@ -2417,7 +2432,7 @@ class Client extends EventEmitter { /** * Get the all of a guild's application command permissions - * @arg {String} guildID The guild id + * @arg {String} guildID The guild ID * @returns {Promise>} Resolves with an array of guild application command permissions objects. */ getGuildCommandPermissions(guildID) { @@ -2429,7 +2444,7 @@ class Client extends EventEmitter { /** * Get a guild's application commands - * @arg {String} guildID The guild id + * @arg {String} guildID The guild ID * @returns {Promise>} Resolves with an array of command objects. */ getGuildCommands(guildID) { @@ -2783,19 +2798,6 @@ class Client extends EventEmitter { return this.requestHandler.request("GET", Endpoints.GUILD_EMOJIS(guildID), true); } - /** - * Get a guild scheduled event data via the REST API. REST mode is required to use this endpoint. - * @arg {String} guildID The guild id to get the event of - * @arg {String} eventID The id of the event - * @returns {Promise} - */ - getRESTGuildEvent(guildID, eventID) { - if(!this.options.restMode) { - return Promise.reject(new Error("Eris REST mode is not enabled")); - } - - return this.requestHandler.request("GET", Endpoints.GUILD_SCHEDULED_EVENT(guildID, eventID), true).then((data) => new GuildEvent(data, this)); - } /** * Get a guild's members via the REST API. REST mode is required to use this endpoint. * @arg {String} guildID The ID of the guild @@ -2874,6 +2876,20 @@ class Client extends EventEmitter { return this.requestHandler.request("GET", Endpoints.USER_GUILDS("@me"), true, options).then((guilds) => guilds.map((guild) => new Guild(guild, this))); } + /** + * Get a guild scheduled event data via the REST API. REST mode is required to use this endpoint. + * @arg {String} guildID The guild ID to get the event of + * @arg {String} eventID The id of the event + * @returns {Promise} + */ + getRESTGuildScheduledEvent(guildID, eventID) { + if(!this.options.restMode) { + return Promise.reject(new Error("Eris REST mode is not enabled")); + } + + return this.requestHandler.request("GET", Endpoints.GUILD_SCHEDULED_EVENT(guildID, eventID), true).then((data) => new GuildScheduledEvent(data, this)); + } + /** * Get a guild sticker via the REST API. REST mode is required to use this endpoint. * @arg {String} guildID The ID of the guild @@ -3119,15 +3135,15 @@ class Client extends EventEmitter { /** * List all scheduled events for the given guild. * @arg {Boolean} withUserCount Include number of users subscribed to each event - * @returns {Promise>} + * @returns {Promise>} */ - listGuildEvents(guildID, withUserCount) { + listGuildScheduledEvents(guildID, withUserCount) { return this.requestHandler.request("GET", Endpoints.GUILD_SCHEDULED_EVENTS(guildID), true, { with_user_count: withUserCount - }).then((events) => events.map((event) => new GuildEvent(event, this))); + }).then((events) => events.map((event) => new GuildScheduledEvent(event, this))); } - listGuildEventUsers(guildID, eventID) { + listGuildScheduledEventUsers(guildID, eventID) { return this.requestHandler.request("GET", Endpoints.GUILD_SCHEDULED_EVENT_USERS(guildID, eventID)); } diff --git a/lib/Constants.js b/lib/Constants.js index 55569a47f..4d157bd16 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -444,14 +444,14 @@ module.exports.PremiumTiers = { TIER_3: 3 }; -module.exports.GuildEventStatus = { +module.exports.GuildScheduledEventStatus = { SCHEDULED: 1, ACTIVE: 2, COMPLETED: 3, CANCELED: 4 }; -module.exports.GuildEventEntityTypes = { +module.exports.GuildScheduledEventEntityTypes = { NONE: 0, STAGE_INSTANCE: 1, VOICE: 2, diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 33a70099f..5b1b8affc 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -15,9 +15,9 @@ const User = require("../structures/User"); const Invite = require("../structures/Invite"); const Interaction = require("../structures/Interaction"); const Constants = require("../Constants"); -const GuildEvent = require("../structures/GuildEvent"); const ThreadChannel = require("../structures/ThreadChannel"); const StageInstance = require("../structures/StageInstance"); +const GuildScheduledEvent = require("../structures/GuildScheduledEvent"); const WebSocket = typeof window !== "undefined" ? require("../util/BrowserWebSocket") : require("ws"); @@ -2323,29 +2323,28 @@ class Shard extends EventEmitter { break; } case "GUILD_SCHEDULED_EVENT_CREATE": { - const event = new GuildEvent(packet.d, this.client); - const guild = this.client.guilds.get(packet.d.guild_id); if(!guild) { - this.emit("debug", `Missing guild ${packet.d.guild_id} in GUILD_SCHEDULED_EVENT_CREATE`); + this.emit("guildScheduledEventCreate", new GuildScheduledEvent(packet.d, this.client)); break; } - guild.events.add(packet.d, this.client); - this.client.guildEventMap[packet.d.id] = packet.d.guild_id; - /** - * Fired when a scheduled guild event is created + * Fired when a guild scheduled event is created * @event Client#guildScheduledEventCreate - * @prop {GuildEvent} event The event + * @prop {GuildScheduledEvent} event The event */ - this.emit("guildScheduledEventCreate", event); + this.emit("guildScheduledEventCreate", guild.events.add(packet.d, this.client)); break; } case "GUILD_SCHEDULED_EVENT_UPDATE": { const guild = this.client.guilds.get(packet.d.guild_id); - let event = guild.events.get(packet.d.id); + if(!guild) { + this.emit("guildScheduledEventUpdate", new GuildScheduledEvent(packet.d, this.client), null); + break; + } + const event = guild.events.get(packet.d.id); let oldEvent = null; if(event) { oldEvent = { @@ -2357,12 +2356,11 @@ class Shard extends EventEmitter { entityType: event.entityType }; } - event = guild.events.update(packet.d, this.client); /** - * Fired when a scheduled guild event is updated + * Fired when a guild scheduled event is updated * @event Client#guildScheduledEventUpdate - * @prop {GuildEvent} event The updated event + * @prop {GuildScheduledEvent} event The updated event * @prop {Object?} oldEvent The old guild event data, or null if the event wasn't cached. * @prop {String} oldEvent.channelID The channel ID of the event * @prop {String} oldEvent.name The name of the event @@ -2371,73 +2369,57 @@ class Shard extends EventEmitter { * @prop {String} oldEvent.description The description of the event * @prop {Number} oldEvent.entityType The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event */ - this.emit("guildScheduledEventUpdate", event, oldEvent); + this.emit("guildScheduledEventUpdate", guild.events.update(packet.d, this.client), oldEvent); break; } case "GUILD_SCHEDULED_EVENT_DELETE": { - delete this.client.guildEventMap[packet.d.id]; const guild = this.client.guilds.get(packet.d.guild_id); - if(!guild) { - this.emit("debug", `Missing guild ${packet.d.guild_id} in GUILD_SCHEDULED_EVENT_DELETE`); - break; - } - const event = guild.events.remove(packet.d); - if(!event) { + this.emit("guildScheduledEventDelete", new GuildScheduledEvent(packet.d, this.client)); break; } /** - * Fired when a scheduled guild event is deleted + * Fired when a guild scheduled event is deleted * @event Client#guildScheduledEventDelete - * @prop {GuildEvent} event The event that was deleted. + * @prop {GuildScheduledEvent} event The event that was deleted. */ - this.emit("guildScheduledEventDelete", event); + this.emit("guildScheduledEventDelete", guild.events.remove(packet.d) || new GuildScheduledEvent(packet.d, this.client)); break; } case "GUILD_SCHEDULED_EVENT_USER_ADD": { - const guild = this.client.guildEventMap[packet.d.guild_scheduled_event_id]; - const user = this.client.users.get(packet.d.user_id) || packet.d.user_id; + const user = this.client.users.get(packet.d.user_id) || {id: packet.d.user_id}; + const guild = this.client.guilds.get(packet.d.guild_id); if(!guild) { - this.emit("guildScheduledEventUserAdd", packet.d.guild_scheduled_event_id, user); - break; - } - - const event = guild.events.get(packet.d.guild_scheduled_event_id); - if(!event) { + this.emit("guildScheduledEventUserAdd", {id: packet.d.guild_scheduled_event_id, guild: {id: packet.d.guild_id}}, user); break; } /** * Fired when an user has subscribed to a Guild Event. * @event Client#guildScheduledEventUserAdd - * @prop {GuildEvent | string} event The guild event that the user subscribed to. This will be the guild event ID if the guild was uncached - * @prop {User | string} user The user that subscribed to the Guild Event. This will be the user ID if the user was uncached + * @prop {GuildScheduledEvent | Object} event The guild event that the user subscribed to. If the event is uncached, this will be an object with `id` and `guild` keys. No other property is guaranteed + * @prop {User | Object} user The user that subscribed to the Guild Event. If the user is uncached, this will be an object with an `id` key. No other property is guaranteed */ - this.emit("guildScheduledEventUserAdd", event, user); + this.emit("guildScheduledEventUserAdd", guild.events.get(packet.d.guild_scheduled_event_id) || {id: packet.d.guild_scheduled_event_id, guild: guild}, user); break; } case "GUILD_SCHEDULED_EVENT_USER_REMOVE": { - const guild = this.client.guildEventMap[packet.d.guild_scheduled_event_id]; - const user = this.client.users.get(packet.d.user_id) || packet.d.user_id; + const user = this.client.users.get(packet.d.user_id) || {id: packet.d.user_id}; + const guild = this.client.guilds.get(packet.d.guild_id); if(!guild) { - this.emit("guildScheduledEventUserRemove", packet.d.guild_scheduled_event_id, user); - break; - } - - const event = guild.events.get(packet.d.guild_scheduled_event_id); - if(!event) { + this.emit("guildScheduledEventUserRemove", {id: packet.d.guild_scheduled_event_id, guild: {id: packet.d.guild_id}}, user); break; } /** * Fired when an user has unsubscribed from a Guild Event. * @event Client#guildScheduledEventUserRemove - * @prop {GuildEvent | string} event The guild event that the user unsubscribed to. This will be the guild event ID if the guild was uncached + * @prop {GuildScheduledEvent | string} event The guild event that the user unsubscribed to. This will be the guild event ID if the guild was uncached * @prop {User | string} user The user that unsubscribed to the Guild Event. This will be the user ID if the user was uncached */ - this.emit("guildScheduledEventUserRemove", event, user); + this.emit("guildScheduledEventUserRemove", guild.events.get(packet.d.guild_scheduled_event_id) || {id: packet.d.guild_scheduled_event_id, guild: guild}, user); break; } case "MESSAGE_ACK": // Ignore these diff --git a/lib/rest/Endpoints.js b/lib/rest/Endpoints.js index 0399173b3..0299b9b3f 100644 --- a/lib/rest/Endpoints.js +++ b/lib/rest/Endpoints.js @@ -63,8 +63,8 @@ module.exports.GUILD_PRUNE = (guildID) module.exports.GUILD_ROLE = (guildID, roleID) => `/guilds/${guildID}/roles/${roleID}`; module.exports.GUILD_ROLES = (guildID) => `/guilds/${guildID}/roles`; module.exports.GUILD_SCHEDULED_EVENT = (guildID, scheduledEventID) => `/guilds/${guildID}/scheduled-events/${scheduledEventID}`; -module.exports.GUILD_SCHEDULED_EVENTS = (guildID) => `/guilds/${guildID}/scheduled-events`; module.exports.GUILD_SCHEDULED_EVENT_USERS = (guildID, scheduledEventID) => `/guilds/${guildID}/scheduled-events/${scheduledEventID}/users`; +module.exports.GUILD_SCHEDULED_EVENTS = (guildID) => `/guilds/${guildID}/scheduled-events`; module.exports.GUILD_STICKER = (guildID, stickerID) => `/guilds/${guildID}/stickers/${stickerID}`; module.exports.GUILD_STICKERS = (guildID) => `/guilds/${guildID}/stickers`; module.exports.GUILD_TEMPLATE = (code) => `/guilds/templates/${code}`; @@ -127,6 +127,7 @@ module.exports.DEFAULT_USER_AVATAR = (userDiscriminator) module.exports.GUILD_AVATAR = (guildID, userID, guildAvatar) => `/guilds/${guildID}/users/${userID}/avatars/${guildAvatar}`; module.exports.GUILD_DISCOVERY_SPLASH = (guildID, guildDiscoverySplash) => `/discovery-splashes/${guildID}/${guildDiscoverySplash}`; module.exports.GUILD_ICON = (guildID, guildIcon) => `/icons/${guildID}/${guildIcon}`; +module.exports.GUILD_SCHEDULED_EVENT_COVER = (eventID, eventIcon) => `guild-events/${eventID}/${eventIcon}`; module.exports.GUILD_SPLASH = (guildID, guildSplash) => `/splashes/${guildID}/${guildSplash}`; module.exports.ROLE_ICON = (roleID, roleIcon) => `/role-icons/${roleID}/${roleIcon}`; module.exports.TEAM_ICON = (teamID, teamIcon) => `/team-icons/${teamID}/${teamIcon}`; diff --git a/lib/rest/RequestHandler.js b/lib/rest/RequestHandler.js index ba5ebc76c..656c81fcd 100644 --- a/lib/rest/RequestHandler.js +++ b/lib/rest/RequestHandler.js @@ -422,7 +422,6 @@ class RequestHandler { return Base.prototype[util.inspect.custom].call(this); } - toString() { return "[RequestHandler]"; } diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 4fe0bbb5c..200aad106 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -9,7 +9,7 @@ const Member = require("./Member"); const Role = require("./Role"); const VoiceState = require("./VoiceState"); const Permission = require("./Permission"); -const GuildEvent = require("./GuildEvent"); +const GuildScheduledEvent = require("./GuildScheduledEvent"); const {Permissions} = require("../Constants"); const StageInstance = require("./StageInstance"); const ThreadChannel = require("./ThreadChannel"); @@ -89,7 +89,7 @@ class Guild extends Base { this.channels = new Collection(GuildChannel); this.threads = new Collection(ThreadChannel); this.members = new Collection(Member); - this.events = new Collection(GuildEvent); + this.events = new Collection(GuildScheduledEvent); this.stageInstances = new Collection(StageInstance); this.memberCount = data.member_count; this.roles = new Collection(Role); @@ -433,24 +433,6 @@ class Guild extends Base { return this._client.createGuildEmoji.call(this._client, this.id, options, reason); } - /** - * Create a scheduled guild event in this guild - * @arg {Object} event The event to be created - * @arg {String} [event.name] The name of the event - * @arg {String} [event.channelID] The channel ID of the event - * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event - * @arg {String} [event.entityMetadata.location] Location of the event - * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {Date} [event.scheduledStartTime] The time the event will start - * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end - * @arg {String} [event.description] The description of the event - * @arg {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event - * @returns {Promise} - */ - createEvent(event) { - return this._client.createGuildEvent.call(this._client, this.id, event); - } - /** * Create a guild role * @arg {Object | Role} [options] An object or Role containing the properties to set @@ -467,6 +449,26 @@ class Guild extends Base { createRole(options, reason) { return this._client.createRole.call(this._client, this.id, options, reason); } + + /** + * Create a guild scheduled event in this guild + * @arg {Object} event The event to be created + * @arg {String} [event.channelID] The channel ID of the event. This is optional if `entityType` is `3` (external) + * @arg {String} [event.description] The description of the event + * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if `entityType` is `3` (external) + * @arg {String} [event.entityMetadata.location] Location of the event + * @arg {Number} event.entityType The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event + * @arg {String} [event.image] Base 64 encoded image for the scheduled event + * @arg {String} event.name The name of the event + * @arg {String} event.privacyLevel The privacy level of the event + * @arg {Date} [event.scheduledEndTime] The time when the event is scheduled to end. This is required if `entityType` is `3` (external) + * @arg {Date} event.scheduledStartTime The time the event will start + * @returns {Promise} + */ + createScheduledEvent(event) { + return this._client.createGuildScheduledEvent.call(this._client, this.id, event); + } + /** * Create a guild sticker * @arg {Object} options Sticker options @@ -482,6 +484,7 @@ class Guild extends Base { createSticker(options, reason) { return this._client.createGuildSticker.call(this._client, this.id, options, reason); } + /** * Create a template for this guild * @arg {String} name The name of the template @@ -491,6 +494,7 @@ class Guild extends Base { createTemplate(name, description) { return this._client.createGuildTemplate.call(this._client, this.id, name, description); } + /** * Delete the guild (bot user must be owner) * @returns {Promise} @@ -498,6 +502,7 @@ class Guild extends Base { delete() { return this._client.deleteGuild.call(this._client, this.id); } + /** * Delete a guild application command * @arg {String} commandID The command id @@ -506,6 +511,7 @@ class Guild extends Base { deleteCommand(commandID) { return this._client.deleteGuildCommand.call(this._client, this.id, commandID); } + /** * Delete a discovery subcategory * @arg {String} categoryID The ID of the discovery category @@ -515,6 +521,7 @@ class Guild extends Base { deleteDiscoverySubcategory(categoryID, reason) { return this._client.addGuildDiscoverySubcategory.call(this._client, this.id, categoryID, reason); } + /** * Delete a emoji in the guild * @arg {String} emojiID The ID of the emoji @@ -524,6 +531,7 @@ class Guild extends Base { deleteEmoji(emojiID, reason) { return this._client.deleteGuildEmoji.call(this._client, this.id, emojiID, reason); } + /** * Delete a guild integration * @arg {String} integrationID The ID of the integration @@ -532,6 +540,7 @@ class Guild extends Base { deleteIntegration(integrationID) { return this._client.deleteGuildIntegration.call(this._client, this.id, integrationID); } + /** * Delete a role * @arg {String} roleID The ID of the role @@ -541,6 +550,7 @@ class Guild extends Base { deleteRole(roleID, reason) { return this._client.deleteRole.call(this._client, this.id, roleID, reason); } + /** * Delete a guild sticker * @arg {String} stickerID The ID of the sticker @@ -981,11 +991,12 @@ class Guild extends Base { /** * Get a guild scheduled event data via the REST API. REST mode is required to use this endpoint. * @arg {String} eventID The id of the event - * @returns {Promise} + * @returns {Promise} */ getRESTEvent(eventID) { - return this._client.getRESTGuildEvent.call(this._client, this.id, eventID); + return this._client.getRESTGuildScheduledEvent.call(this._client, this.id, eventID); } + /** * Get a guild's members via the REST API. REST mode is required to use this endpoint. * @arg {String} memberID The ID of the member @@ -1015,9 +1026,6 @@ class Guild extends Base { return this._client.getRESTGuildRoles.call(this._client, this.id); } - - - /** * Get a guild sticker via the REST API. REST mode is required to use this endpoint. * @arg {String} stickerID The ID of the sticker @@ -1119,10 +1127,10 @@ class Guild extends Base { /** * List all scheduled events for this guild * @arg {Boolean} withUserCount Whether to include number of users subscribed to each event - * @returns {Promise>} + * @returns {Promise>} */ listEvents(withUserCount) { - return this._client.listGuildEvents.call(this._client, this.id, withUserCount); + return this._client.listGuildScheduledEvents.call(this._client, this.id, withUserCount); } /** @@ -1131,7 +1139,7 @@ class Guild extends Base { * @returns {} */ listEventUsers(eventID) { - return this._client.listGuildEventUsers.call(this._client, this.id, eventID); + return this._client.listGuildScheduledEventUsers.call(this._client, this.id, eventID); } /** diff --git a/lib/structures/GuildEvent.js b/lib/structures/GuildScheduledEvent.js similarity index 57% rename from lib/structures/GuildEvent.js rename to lib/structures/GuildScheduledEvent.js index f4bc2d419..e68a801c4 100644 --- a/lib/structures/GuildEvent.js +++ b/lib/structures/GuildScheduledEvent.js @@ -1,41 +1,54 @@ "use strict"; const Base = require("./Base"); -const User = require("./User"); +const Endpoints = require("../rest/Endpoints"); /** * Represents a guild scheduled event +* @prop {(VoiceChannel | StageChannel | Object)?} channel The channel where the event will be held. This will be null if the event is external (`entityType` is `3`). Can be partial with only `id` if the channel or guild is not cached +* @prop {User?} creator The user that created the scheduled event. For events created before October 25 2021, this will be null. Please see the relevant Discord documentation for more details +* @prop {String?} description The description of the event +* @prop {String?} entityID Entity id +* @prop {Object?} entityMetadata Metadata for the event. This will be null if the event is not external (`entityType` is not `3`) +* @prop {String} entityMetadata.location Location of the event +* @prop {Number} entityType The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event +* @prop {Guild | Object} guild The guild which the event belongs to. Can be partial with only `id` if not cached * @prop {String} id The id of the guild event -* @prop {String} guildID The guild id of the event -* @prop {String} channelID The channel id of the event +* @prop {String?} image The hash of the event's image, or null if no image +* @prop {String?} imageURL The URL of the event's image, or null if no image * @prop {String} name The name of the event -* @prop {String?} description The description of the event -* @prop {Number} scheduledStartTime The time the event will start -* @prop {Number} scheduledEndTime The time the event will end, or null if the event does not have a scheduled time to end * @prop {Number} privacyLevel Event privacy level +* @prop {Number} scheduledStartTime The time the event will start +* @prop {Number?} scheduledEndTime The time the event will end, or null if the event does not have a scheduled time to end * @prop {Number} status The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event -* @prop {Number} entityType The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event -* @prop {String} entityID Entity id -* @prop {Object} entityMetadata Metadata for the event -* @prop {String} entityMetadata.location Location of the event -* @prop {User} creator The user that created the scheduled event -* @prop {Number?} userCount Users subscribed to the event +* @prop {Number?} userCount The number of users subscribed to the event */ -class GuildEvent extends Base { +class GuildScheduledEvent extends Base { constructor(data, client) { super(data.id); this._client = client; + if(data.creator !== undefined) { + this.creator = client.users.update(data.creator, this.client); + } else { + this.creator = null; + } + this.guild = client.guilds.get(data.guild_id) || {id: data.guild_id}; this.scheduledEndTime = null; this.update(data); } update(data) { - if(data.guild_id !== undefined) { - this.guildID = data.guild_id; - } if(data.channel_id !== undefined) { - this.channelID = data.channel_id; + if(data.channel_id !== null) { + if(this._client.guilds.get(data.guild_id)) { + this.channel = this._client.guilds.get(data.guild_id).channels.get(data.channel_id) || {id: data.channel_id}; + } else { + this.channel = {id: data.channel_id}; + } + } else { + this.channel = null; + } } if(data.name !== undefined) { this.name = data.name; @@ -64,12 +77,16 @@ class GuildEvent extends Base { if(data.entity_metadata !== undefined) { this.entityMetadata = {location: data.location}; } - if(data.creator !== undefined) { - this.creator = new User(data.creator ,this._client); - } if(data.user_count !== undefined) { this.userCount = data.user_count; } + if(data.image !== undefined) { + this.image = data.image; + } + } + + get imageURL() { + return this.image ? this._client._formatImage(Endpoints.GUILD_SCHEDULED_EVENT_COVER(this.id, this.image)) : null; } /** @@ -77,26 +94,28 @@ class GuildEvent extends Base { * @returns {Promise} */ delete() { - return this._client.deleteGuildEvent.call(this._client, this.guildID, this.id); + return this._client.deleteGuildScheduledEvent.call(this._client, this.guildID, this.id); } /** * Edit this scheduled event - * @arg {Object} event The new scheuled guild event object + * @arg {Object} event The new guild scheduled event object + * @arg {String} [event.channelID] The channel ID of the event. If updating `entityType` to `3` (external), this **must** be set to `null` + * @arg {String} [event.description] The description of the event + * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if updating `entityType` to `3` (external) + * @arg {String} [event.entityMetadata.location] Location of the event. This is required if updating `entityType` to `3` (external) + * @arg {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event + * @arg {String} [event.image] Base 64 encoded image for the event * @arg {String} [event.name] The name of the event - * @arg {String} [event.channelID] The channel ID of the event - * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event - * @arg {String} [event.entityMetadata.location] Location of the event * @arg {String} [event.privacyLevel] The privacy level of the event + * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end. This is required if updating `entityType` to `3` (external) * @arg {Date} [event.scheduledStartTime] The time the event will start - * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end - * @arg {String} [event.description] The description of the event - * @arg {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event * @arg {Number} [event.status] The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event - * @returns {Promise} + * @arg {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} */ edit(event) { - return this._client.editGuildEvent.call(this._client, this.guildID, this.id, event); + return this._client.editGuildScheduledEvent.call(this._client, this.guildID, this.id, event); } /** @@ -104,7 +123,7 @@ class GuildEvent extends Base { * @returns {} */ listUsers() { - return this._client.listGuildEventUsers.call(this._client, this.guildID, this.id); + return this._client.listGuildScheduledEventUsers.call(this._client, this.guildID, this.id); } toJSON(props = []) { @@ -127,4 +146,4 @@ class GuildEvent extends Base { } } -module.exports = GuildEvent; +module.exports = GuildScheduledEvent; diff --git a/lib/structures/NewsChannel.js b/lib/structures/NewsChannel.js index 851fcc915..c9deea28d 100644 --- a/lib/structures/NewsChannel.js +++ b/lib/structures/NewsChannel.js @@ -12,6 +12,7 @@ class NewsChannel extends TextChannel { this.rateLimitPerUser = 0; this.update(data); } + /** * Crosspost (publish) a message to subscribed channels * @arg {String} messageID The ID of the message diff --git a/lib/structures/PrivateChannel.js b/lib/structures/PrivateChannel.js index f3dff09c8..065af4b91 100644 --- a/lib/structures/PrivateChannel.js +++ b/lib/structures/PrivateChannel.js @@ -209,7 +209,6 @@ class PrivateChannel extends Channel { return this.client.removeMessageReaction.call(this.client, this.id, messageID, reaction, userID); } - /** * [USER ACCOUNT] Ring fellow group channel recipient(s) * @arg {Array} recipients The IDs of the recipients to ring diff --git a/lib/voice/SharedStream.js b/lib/voice/SharedStream.js index 351dc9e37..d4dc133b2 100644 --- a/lib/voice/SharedStream.js +++ b/lib/voice/SharedStream.js @@ -34,7 +34,6 @@ class SharedStream extends EventEmitter { this.voiceConnections = new Collection(VoiceConnection); - if(!VoiceConnection._converterCommand.cmd) { VoiceConnection._converterCommand.pickCommand(); } From 3d143ad2d9b8727608a4dae462c42f5726b3c01b Mon Sep 17 00:00:00 2001 From: Bsian Date: Wed, 13 Apr 2022 14:00:18 +0100 Subject: [PATCH 62/70] [INCOMPLETE] Fix PR --- lib/Client.js | 69 ++++++++++++++------- lib/structures/Guild.js | 86 +++++++++++++++++++++------ lib/structures/GuildScheduledEvent.js | 13 ++-- 3 files changed, 124 insertions(+), 44 deletions(-) diff --git a/lib/Client.js b/lib/Client.js index 05913b790..ef2ec8bf0 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -1575,7 +1575,7 @@ class Client extends EventEmitter { /** * Edit a guild scheduled event * @arg {String} guildID The guild ID where the event will be edited - * @arg {String} eventID The id of the guild scheduled event to be edited + * @arg {String} eventID The guild scheduled event ID to be edited * @arg {Object} event The new guild scheduled event object * @arg {String} [event.channelID] The channel ID of the event. If updating `entityType` to `3` (external), this **must** be set to `null` * @arg {String} [event.description] The description of the event @@ -2488,6 +2488,45 @@ class Client extends EventEmitter { return this.requestHandler.request("GET", Endpoints.GUILD_PREVIEW(guildID), true).then((data) => new GuildPreview(data, this)); } + /** + * Get a guild's scheduled events + * @arg {String} guildID The ID of the guild + * @arg {Object} [options] Options for the request + * @arg {Boolean} [options.withUserCount] Whether to include the number of users subscribed to each event + * @returns {Promise>} + */ + getGuildScheduledEvents(guildID, options = {}) { + options.with_user_count = options.withUserCount; + return this.requestHandler.request("GET", Endpoints.GUILD_SCHEDULED_EVENTS(guildID), true, options).then((data) => data.map((event) => new GuildScheduledEvent(event, this))); + } + + /** + * Get a list of users subscribed to a guild scheduled event + * @arg {String} guildID The ID of the guild + * @arg {String} eventID The ID of the event + * @arg {Object} [options] Options for the request + * @arg {String} [options.after] Get users after this user ID. If `options.before` is provided, this will be ignored. Fetching users in between `before` and `after` is not supported + * @arg {String} [options.before] Get users before this user ID + * @arg {Number} [options.limit=100] The number of users to get (max 100). Pagination will only work if one of `options.after` or `options.after` is also provided + * @arg {Boolean} [withMember] Include guild member data + * @returns {Promise>} + */ + getGuildScheduledEventUsers(guildID, eventID, options = {}) { + const guild = this.guilds.get(guildID); + + options.with_member = options.withMember; + return this.requestHandler.request("GET", Endpoints.GUILD_SCHEDULED_EVENT_USERS(guildID, eventID), true, options).then((data) => data.map((eventUser) => { + if(eventUser.member) { + eventUser.member.id = eventUser.user.id; + } + return { + guildScheduledEventID: eventUser.guild_scheduled_event_id, + member: eventUser.member && guild ? guild.members.update(eventUser.member) : new Member(eventUser.member), + user: this.users.update(eventUser.user) + }; + })); + } + /** * Get a guild template * @arg {String} code The template code @@ -2877,17 +2916,20 @@ class Client extends EventEmitter { } /** - * Get a guild scheduled event data via the REST API. REST mode is required to use this endpoint. - * @arg {String} guildID The guild ID to get the event of - * @arg {String} eventID The id of the event + * Get a guild scheduled event via the REST API. REST mode is required to use this endpoint. + * @arg {String} guildID The ID of the guild + * @arg {String} eventID The ID of the guild scheduled event + * @arg {Object} [options] Options for the request + * @arg {Boolean} [options.withUserCount] Whether to include the number of users subscribed to the event * @returns {Promise} */ - getRESTGuildScheduledEvent(guildID, eventID) { + getRESTGuildScheduledEvent(guildID, eventID, options = {}) { if(!this.options.restMode) { return Promise.reject(new Error("Eris REST mode is not enabled")); } - return this.requestHandler.request("GET", Endpoints.GUILD_SCHEDULED_EVENT(guildID, eventID), true).then((data) => new GuildScheduledEvent(data, this)); + options.with_user_count = options.withUserCount; + return this.requestHandler.request("GET", Endpoints.GUILD_SCHEDULED_EVENT(guildID, eventID), true, options).then((data) => new GuildScheduledEvent(data, this)); } /** @@ -3132,21 +3174,6 @@ class Client extends EventEmitter { this.closeVoiceConnection(this.channelGuildMap[channelID]); } - /** - * List all scheduled events for the given guild. - * @arg {Boolean} withUserCount Include number of users subscribed to each event - * @returns {Promise>} - */ - listGuildScheduledEvents(guildID, withUserCount) { - return this.requestHandler.request("GET", Endpoints.GUILD_SCHEDULED_EVENTS(guildID), true, { - with_user_count: withUserCount - }).then((events) => events.map((event) => new GuildScheduledEvent(event, this))); - } - - listGuildScheduledEventUsers(guildID, eventID) { - return this.requestHandler.request("GET", Endpoints.GUILD_SCHEDULED_EVENT_USERS(guildID, eventID)); - } - /** * Pin a message * @arg {String} channelID The ID of the channel diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 200aad106..1550f6710 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -451,7 +451,7 @@ class Guild extends Base { } /** - * Create a guild scheduled event in this guild + * Create a guild scheduled event * @arg {Object} event The event to be created * @arg {String} [event.channelID] The channel ID of the event. This is optional if `entityType` is `3` (external) * @arg {String} [event.description] The description of the event @@ -551,6 +551,15 @@ class Guild extends Base { return this._client.deleteRole.call(this._client, this.id, roleID, reason); } + /** + * Delete a guild scheduled event + * @arg {String} eventID The ID of the event + * @returns {Promise} + */ + deleteScheduledEvent(eventID) { + return this._client.deleteGuildScheduledEvent.call(this._client, this.id, eventID); + } + /** * Delete a guild sticker * @arg {String} stickerID The ID of the sticker @@ -746,6 +755,28 @@ class Guild extends Base { return this._client.editRole.call(this._client, this.id, roleID, options, reason); } + /** + * Edit this scheduled event + * @arg {String} eventID The guild scheduled event ID + * @arg {Object} event The new guild scheduled event object + * @arg {String} [event.channelID] The channel ID of the event. If updating `entityType` to `3` (external), this **must** be set to `null` + * @arg {String} [event.description] The description of the event + * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if updating `entityType` to `3` (external) + * @arg {String} [event.entityMetadata.location] Location of the event. This is required if updating `entityType` to `3` (external) + * @arg {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event + * @arg {String} [event.image] Base 64 encoded image for the event + * @arg {String} [event.name] The name of the event + * @arg {String} [event.privacyLevel] The privacy level of the event + * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end. This is required if updating `entityType` to `3` (external) + * @arg {Date} [event.scheduledStartTime] The time the event will start + * @arg {Number} [event.status] The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event + * @arg {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ + editScheduledEvent(eventID, event, reason) { + return this._client.editGuildScheduledEvent.call(this._client, this.id, eventID, event, reason); + } + /** * Edit a guild sticker * @arg {String} stickerID The ID of the sticker @@ -1026,6 +1057,17 @@ class Guild extends Base { return this._client.getRESTGuildRoles.call(this._client, this.id); } + /** + * Get a guild scheduled event via the REST API. REST mode is required to use this endpoint. + * @arg {String} eventID The ID of the guild scheduled event + * @arg {Object} [options] Options for the request + * @arg {Boolean} [options.withUserCount] Whether to include the number of users subscribed to the event + * @returns {Promise} + */ + getRESTScheduledEvent(eventID, options) { + return this._client.getRESTGuildScheduledEvent.call(this._client, this.id, eventID, options); + } + /** * Get a guild sticker via the REST API. REST mode is required to use this endpoint. * @arg {String} stickerID The ID of the sticker @@ -1043,6 +1085,30 @@ class Guild extends Base { return this._client.getRESTGuildStickers.call(this._client, this.id); } + /** + * Get the guild's scheduled events + * @arg {Object} [options] Options for the request + * @arg {Boolean} [options.withUserCount] Whether to include the number of users subscribed to each event + * @returns {Promise>} + */ + getScheduledEvents(options) { + return this._client.getGuildScheduledEvents.call(this._client, this.id, options); + } + + /** + * Get a list of users subscribed to a guild scheduled event + * @arg {String} eventID The ID of the event + * @arg {Object} [options] Options for the request + * @arg {String} [options.after] Get users after this user ID. If `options.before` is provided, this will be ignored. Fetching users in between `before` and `after` is not supported + * @arg {String} [options.before] Get users before this user ID + * @arg {Number} [options.limit=100] The number of users to get (max 100). Pagination will only work if one of `options.after` or `options.after` is also provided + * @arg {Boolean} [withMember] Include guild member data + * @returns {Promise} + */ + getScheduledEventUsers(eventID, options) { + return this._client.getGuildScheduledEventUsers.call(this._client, this.id, eventID, options); + } + /** * Get the guild's templates * @returns {Promise>} @@ -1124,24 +1190,6 @@ class Guild extends Base { this._client.closeVoiceConnection.call(this._client, this.id); } - /** - * List all scheduled events for this guild - * @arg {Boolean} withUserCount Whether to include number of users subscribed to each event - * @returns {Promise>} - */ - listEvents(withUserCount) { - return this._client.listGuildScheduledEvents.call(this._client, this.id, withUserCount); - } - - /** - * List all users that subscribed to the given event - * @arg {String} eventID The event id - * @returns {} - */ - listEventUsers(eventID) { - return this._client.listGuildScheduledEventUsers.call(this._client, this.id, eventID); - } - /** * Get the guild permissions of a member * @arg {String | Member | Object} memberID The ID of the member or a Member object diff --git a/lib/structures/GuildScheduledEvent.js b/lib/structures/GuildScheduledEvent.js index e68a801c4..b3d5131a0 100644 --- a/lib/structures/GuildScheduledEvent.js +++ b/lib/structures/GuildScheduledEvent.js @@ -119,11 +119,16 @@ class GuildScheduledEvent extends Base { } /** - * List all users that subscribed to this event - * @returns {} + * Get a list of users subscribed to the guild scheduled event + * @arg {Object} [options] Options for the request + * @arg {String} [options.after] Get users after this user ID. If `options.before` is provided, this will be ignored. Fetching users in between `before` and `after` is not supported + * @arg {String} [options.before] Get users before this user ID + * @arg {Number} [options.limit=100] The number of users to get (max 100). Pagination will only work if one of `options.after` or `options.after` is also provided + * @arg {Boolean} [withMember] Include guild member data + * @returns {Promise>} */ - listUsers() { - return this._client.listGuildScheduledEventUsers.call(this._client, this.guildID, this.id); + getUsers(options) { + return this._client.getGuildScheduledEventUsers.call(this._client, this.guild.id, this.id, options); } toJSON(props = []) { From 074af8eadc5a1f8f1155cdb804ec169aa7d01ad5 Mon Sep 17 00:00:00 2001 From: Bsian Date: Wed, 13 Apr 2022 15:05:48 +0100 Subject: [PATCH 63/70] [INCOMPLETE] Fix PR --- lib/Constants.js | 3 +-- lib/gateway/Shard.js | 39 ++++++++++++++++++++------- lib/structures/GuildScheduledEvent.js | 4 +-- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/lib/Constants.js b/lib/Constants.js index 4d157bd16..cb8b536ff 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -452,10 +452,9 @@ module.exports.GuildScheduledEventStatus = { }; module.exports.GuildScheduledEventEntityTypes = { - NONE: 0, STAGE_INSTANCE: 1, VOICE: 2, - LOCATION: 3 + EXTERNAL: 3 }; module.exports.GuildScheduledEventPrivacyLevel = { diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 5b1b8affc..4b7af8885 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -2348,12 +2348,17 @@ class Shard extends EventEmitter { let oldEvent = null; if(event) { oldEvent = { - channelID: event.channelID, + channel: event.channel, + description: event.description, + entityID: event.entityID, + enitityMetadata: event.entityMetadata, + entityType: event.entityType, + image: event.image, name: event.name, privacyLevel: event.privacyLevel, + scheduledEndTime: event.scheduledEndTime, scheduledStartTime: event.scheduledStartTime, - description: event.description, - entityType: event.entityType + status: event.status }; } @@ -2362,12 +2367,18 @@ class Shard extends EventEmitter { * @event Client#guildScheduledEventUpdate * @prop {GuildScheduledEvent} event The updated event * @prop {Object?} oldEvent The old guild event data, or null if the event wasn't cached. - * @prop {String} oldEvent.channelID The channel ID of the event + * @prop {(VoiceChannel | StageChannel | Object)?} oldEvent.channel The channel where the event is held + * @prop {String?} oldEvent.description The description of the event + * @prop {String?} oldEvent.entityID The Entity ID associated to the event + * @prop {Object?} oldEvent.entityMetadata Metadata for the event + * @prop {String?} oldEvent.enitityMetadata.location Location of the event + * @prop {Number} oldEvent.entityType The event entity type + * @prop {String?} oldEvent.image The hash of the event's image * @prop {String} oldEvent.name The name of the event * @prop {Number} oldEvent.privacyLevel The privacy level of the event - * @prop {Date} oldEvent.scheduledStartTime The time the event will start - * @prop {String} oldEvent.description The description of the event - * @prop {Number} oldEvent.entityType The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event + * @prop {Number?} oldEvent.scheduledEndTime The time the event will start + * @prop {Number} oldEvent.scheduledStartTime The time the event will start + * @prop {Number} oldEvent.status The status of the guild scheduled event */ this.emit("guildScheduledEventUpdate", guild.events.update(packet.d, this.client), oldEvent); break; @@ -2395,13 +2406,18 @@ class Shard extends EventEmitter { break; } + const event = guild.events.get(packet.d.guild_scheduled_event_id); + if(event) { + ++event.userCount; + } + /** * Fired when an user has subscribed to a Guild Event. * @event Client#guildScheduledEventUserAdd * @prop {GuildScheduledEvent | Object} event The guild event that the user subscribed to. If the event is uncached, this will be an object with `id` and `guild` keys. No other property is guaranteed * @prop {User | Object} user The user that subscribed to the Guild Event. If the user is uncached, this will be an object with an `id` key. No other property is guaranteed */ - this.emit("guildScheduledEventUserAdd", guild.events.get(packet.d.guild_scheduled_event_id) || {id: packet.d.guild_scheduled_event_id, guild: guild}, user); + this.emit("guildScheduledEventUserAdd", event || {id: packet.d.guild_scheduled_event_id, guild: guild}, user); break; } case "GUILD_SCHEDULED_EVENT_USER_REMOVE": { @@ -2413,13 +2429,18 @@ class Shard extends EventEmitter { break; } + const event = guild.events.get(packet.d.guild_scheduled_event_id); + if(event) { + --event.userCount; + } + /** * Fired when an user has unsubscribed from a Guild Event. * @event Client#guildScheduledEventUserRemove * @prop {GuildScheduledEvent | string} event The guild event that the user unsubscribed to. This will be the guild event ID if the guild was uncached * @prop {User | string} user The user that unsubscribed to the Guild Event. This will be the user ID if the user was uncached */ - this.emit("guildScheduledEventUserRemove", guild.events.get(packet.d.guild_scheduled_event_id) || {id: packet.d.guild_scheduled_event_id, guild: guild}, user); + this.emit("guildScheduledEventUserRemove", event || {id: packet.d.guild_scheduled_event_id, guild: guild}, user); break; } case "MESSAGE_ACK": // Ignore these diff --git a/lib/structures/GuildScheduledEvent.js b/lib/structures/GuildScheduledEvent.js index b3d5131a0..c018aa439 100644 --- a/lib/structures/GuildScheduledEvent.js +++ b/lib/structures/GuildScheduledEvent.js @@ -8,9 +8,9 @@ const Endpoints = require("../rest/Endpoints"); * @prop {(VoiceChannel | StageChannel | Object)?} channel The channel where the event will be held. This will be null if the event is external (`entityType` is `3`). Can be partial with only `id` if the channel or guild is not cached * @prop {User?} creator The user that created the scheduled event. For events created before October 25 2021, this will be null. Please see the relevant Discord documentation for more details * @prop {String?} description The description of the event -* @prop {String?} entityID Entity id +* @prop {String?} entityID The entity ID associated to the event * @prop {Object?} entityMetadata Metadata for the event. This will be null if the event is not external (`entityType` is not `3`) -* @prop {String} entityMetadata.location Location of the event +* @prop {String?} entityMetadata.location Location of the event * @prop {Number} entityType The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event * @prop {Guild | Object} guild The guild which the event belongs to. Can be partial with only `id` if not cached * @prop {String} id The id of the guild event From 7f3157bd55777b7b7208d911ec8c580186d6f8c7 Mon Sep 17 00:00:00 2001 From: Bsian Date: Wed, 13 Apr 2022 15:20:32 +0100 Subject: [PATCH 64/70] Fix PR --- index.d.ts | 114 +++++++++++++++++++++++++++------------- lib/structures/Guild.js | 11 +--- 2 files changed, 78 insertions(+), 47 deletions(-) diff --git a/index.d.ts b/index.d.ts index e4bd4ecd2..3804b4dc8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -56,6 +56,7 @@ declare namespace Eris { type GuildTextableChannel = TextChannel | NewsChannel; type GuildTextableWithThread = GuildTextableChannel | AnyThreadChannel; type InviteChannel = InvitePartialChannel | Exclude; + type PossiblyUncachedSpeakableChannel = VoiceChannel | StageChannel | Uncached; type PossiblyUncachedTextable = Textable | Uncached; type PossiblyUncachedTextableChannel = TextableChannel | Uncached; type TextableChannel = (GuildTextable & GuildTextableChannel) | (ThreadTextable & AnyThreadChannel) | (Textable & PrivateChannel); @@ -86,12 +87,13 @@ declare namespace Eris { // Guild type DefaultNotifications = Constants["DefaultMessageNotificationLevels"][keyof Constants["DefaultMessageNotificationLevels"]]; type ExplicitContentFilter = Constants["ExplicitContentFilterLevels"][keyof Constants["ExplicitContentFilterLevels"]]; + type GuildFeatures = Constants["GuildFeatures"][number]; type GuildScheduledEventEntityTypes = Constants["GuildScheduledEventEntityTypes"][keyof Constants["GuildScheduledEventEntityTypes"]]; type GuildScheduledEventPrivacyLevel = Constants["GuildScheduledEventPrivacyLevel"][keyof Constants["GuildScheduledEventPrivacyLevel"]]; type GuildScheduledEventStatus = Constants["GuildScheduledEventStatus"][keyof Constants["GuildScheduledEventStatus"]]; - type GuildFeatures = Constants["GuildFeatures"][number]; type NSFWLevel = Constants["GuildNSFWLevels"][keyof Constants["GuildNSFWLevels"]]; type PossiblyUncachedGuild = Guild | Uncached; + type PossiblyUncachedGuildScheduledEvent = GuildScheduledEvent | Uncached; type PremiumTier = Constants["PremiumTiers"][keyof Constants["PremiumTiers"]]; type VerificationLevel = Constants["VerificationLevels"][keyof Constants["VerificationLevels"]]; type SystemChannelFlags = Constants["SystemChannelFlags"][keyof Constants["SystemChannelFlags"]]; @@ -615,6 +617,19 @@ declare namespace Eris { topic?: string | null; type: GuildChannelTypes; } + interface OldGuildScheduledEvent { + channel: PossiblyUncachedSpeakableChannel | null; + description?: string; + entityID?: string; + enitityMetadata?: GuildScheduledEventMetadata; + entityType: GuildScheduledEventEntityTypes; + image?: string; + name: string; + privacyLevel: GuildScheduledEventPrivacyLevel; + scheduledEndTime: number | null; + scheduledStartTime: number; + status: GuildScheduledEventStatus; + } interface OldGuildTextChannel extends OldGuildChannel { nsfw: boolean; rateLimitPerUser: number; @@ -712,6 +727,11 @@ declare namespace Eris { guildRoleCreate: [guild: Guild, role: Role]; guildRoleDelete: [guild: Guild, role: Role]; guildRoleUpdate: [guild: Guild, role: Role, oldRole: OldRole]; + guildScheduledEventCreate: [event: GuildScheduledEvent]; + guildScheduledEventDelete: [event: GuildScheduledEvent]; + guildScheduledEventUpdate: [event: GuildScheduledEvent, oldEvent: OldGuildScheduledEvent | null]; + guildScheduledEventUserAdd: [event: PossiblyUncachedGuildScheduledEvent, user: User | Uncached]; + guildScheduledEventUserRemove: [event: PossiblyUncachedGuildScheduledEvent, user: User | Uncached]; guildStickersUpdate: [guild: PossiblyUncachedGuild, stickers: Sticker[], oldStickers: Sticker[] | null]; guildUnavailable: [guild: UnavailableGuild]; guildUpdate: [guild: Guild, oldGuild: OldGuild]; @@ -755,11 +775,6 @@ declare namespace Eris { voiceStateUpdate: [member: Member, oldState: OldVoiceState]; warn: [message: string, id?: number]; webhooksUpdate: [data: WebhookData]; - guildScheduledEventCreate: [event: GuildScheduledEvent]; - guildScheduledEventUpdate: [event: GuildScheduledEvent, oldEvent: GuildScheduledEventOptions | null]; - guildScheduledEventDelete: [event: GuildScheduledEvent]; - guildScheduledEventUserAdd: [event: GuildScheduledEvent | string, user: User | string]; - guildScheduledEventUserRemove: [event: GuildScheduledEvent | string, user: User | string]; } interface ClientEvents extends EventListeners { shardDisconnect: [err: Error | undefined, id: number]; @@ -868,6 +883,15 @@ declare namespace Eris { limit?: number; userID?: string; } + interface GetGuildScheduledEventOptions { + withUserCount?: boolean; + } + interface GetGuildScheduledEventUsersOptions { + after?: string; + before?: string; + limit?: number; + withMember?: boolean; + } interface GetPruneOptions { days?: number; includeRoles?: string[]; @@ -908,6 +932,34 @@ declare namespace Eris { systemChannelID?: string; verificationLevel?: VerificationLevel; } + interface GuildScheduledEventMetadata { + location?: string; + } + interface GuildScheduledEventEditOptions { + channelID: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? null | undefined : string | undefined; + description?: string | null; + entityMetadata: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? Required : GuildScheduledEventMetadata | null | undefined; + entityType?: T; + image?: string; + name?: string; + privacyLevel?: GuildScheduledEventPrivacyLevel; + scheduledEndTime: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? Date : Date | undefined + scheduledStartTime?: Date; + status?: GuildScheduledEventStatus; + } + interface GuildScheduledEventOptions extends Omit, "status"> { + channelID: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? undefined : string; + entityMetadata: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? Required : GuildScheduledEventMetadata | undefined; + entityType: T; + name: string; + privacyLevel: GuildScheduledEventPrivacyLevel; + scheduledStartTime: Date; + } + interface GuildScheduledEventUser { + guildScheduledEventID: string; + user: User; + member?: Member; + } interface GuildTemplateOptions { name?: string; description?: string | null; @@ -1453,22 +1505,6 @@ declare namespace Eris { team_id: string; user: PartialUser; } - interface GuildScheduledEventMetadata { - location?: string; - } - interface GuildScheduledEventOptions { - name: string; - channelID: string; - entityMetadata: GuildScheduledEventMetadata; - privacyLevel: GuildScheduledEventPrivacyLevel; - scheduledStartTime: Date; - scheduledEndTime: Date; - description: string; - entityType: GuildScheduledEventEntityTypes; - } - interface GuildScheduledEventEditOptions extends GuildScheduledEventOptions { - status: GuildScheduledEventStatus; - } interface Constants { GATEWAY_VERSION: 9; REST_VERSION: 9; @@ -1953,10 +1989,9 @@ declare namespace Eris { CANCELED: 4; }; GuildScheduledEventEntityTypes: { - NONE: 0; STAGE_INSTANCE: 1; VOICE: 2; - LOCATION: 3; + EXTERNAL: 3; }; GuildScheduledEventPrivacyLevel: { PUBLIC: 1; @@ -2274,7 +2309,7 @@ declare namespace Eris { createGuild(name: string, options?: CreateGuildOptions): Promise; createGuildCommand(guildID: string, command: ApplicationCommandStructure): Promise; createGuildEmoji(guildID: string, options: EmojiOptions, reason?: string): Promise; - createGuildScheduledEvent(guildID: string, event: GuildScheduledEventOptions): Promise; + createGuildScheduledEvent(guildID: string, event: GuildScheduledEventOptions): Promise>; createGuildFromTemplate(code: string, name: string, icon?: string): Promise; createGuildSticker(guildID: string, options: CreateStickerOptions, reason?: string): Promise; createGuildTemplate(guildID: string, name: string, description?: string | null): Promise; @@ -2334,7 +2369,7 @@ declare namespace Eris { options: { name?: string; roles?: string[] }, reason?: string ): Promise; - editGuildScheduledEvent(event: GuildScheduledEventEditOptions, eventID: string): Promise; + editGuildScheduledEvent(guildID: string, eventID: string, event: GuildScheduledEventEditOptions, reason: string): Promise>; editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise; editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise; editGuildSticker(guildID: string, stickerID: string, options?: EditStickerOptions, reason?: string): Promise; @@ -2412,6 +2447,8 @@ declare namespace Eris { getGuildIntegrations(guildID: string): Promise; getGuildInvites(guildID: string): Promise; getGuildPreview(guildID: string): Promise; + getGuildScheduledEvents(guildID: string, options?: GetGuildScheduledEventOptions): Promise + getGuildScheduledEventUsers(guildID: string, eventID: string, options?: GetGuildScheduledEventUsersOptions): Promise; getGuildTemplate(code: string): Promise; getGuildTemplates(guildID: string): Promise; getGuildVanity(guildID: string): Promise; @@ -2438,7 +2475,7 @@ declare namespace Eris { getRESTGuildChannels(guildID: string): Promise; getRESTGuildEmoji(guildID: string, emojiID: string): Promise; getRESTGuildEmojis(guildID: string): Promise; - getRESTGuildScheduledEvent(guildID: string, eventID: string): Promise; + getRESTGuildScheduledEvent(guildID: string, eventID: string, options?: GetGuildScheduledEventOptions): Promise; getRESTGuildMember(guildID: string, memberID: string): Promise; getRESTGuildMembers(guildID: string, options?: GetRESTGuildMembersOptions): Promise; /** @deprecated */ @@ -2498,8 +2535,6 @@ declare namespace Eris { leaveGuild(guildID: string): Promise; leaveThread(channelID: string, userID?: string): Promise; leaveVoiceChannel(channelID: string): void; - listGuildScheduledEvents(guildID: string, withUserCount: boolean): Promise>; - listGuildScheduledEventUsers(guildID: string, eventID: string): void; off(event: K, listener: (...args: ClientEvents[K]) => void): this; off(event: string, listener: (...args: any[]) => void): this; once(event: K, listener: (...args: ClientEvents[K]) => void): this; @@ -2753,6 +2788,7 @@ declare namespace Eris { deleteEmoji(emojiID: string, reason?: string): Promise; deleteIntegration(integrationID: string): Promise; deleteRole(roleID: string): Promise; + deleteScheduledEvent(eventID: string): Promise; deleteSticker(stickerID: string, reason?: string): Promise; deleteTemplate(code: string): Promise; dynamicBannerURL(format?: ImageFormat, size?: number): string | null; @@ -2769,6 +2805,7 @@ declare namespace Eris { /** @deprecated */ editNickname(nick: string): Promise; editRole(roleID: string, options: RoleOptions): Promise; + editScheduledEvent(eventID: string, event: GuildScheduledEventEditOptions, reason?: string): Promise> editSticker(stickerID: string, options?: EditStickerOptions, reason?: string): Promise; editTemplate(code: string, options: GuildTemplateOptions): Promise; editVanity(code: string | null): Promise; @@ -2795,14 +2832,16 @@ declare namespace Eris { getRESTChannels(): Promise; getRESTEmoji(emojiID: string): Promise; getRESTEmojis(): Promise; - getRESTEvent(eventID: string): Promise; getRESTMember(memberID: string): Promise; getRESTMembers(options?: GetRESTGuildMembersOptions): Promise; /** @deprecated */ getRESTMembers(limit?: number, after?: string): Promise; getRESTRoles(): Promise; + getRESTScheduledEvent(eventID: string): Promise; getRESTSticker(stickerID: string): Promise; getRESTStickers(): Promise; + getScheduledEvents(options?: GetGuildScheduledEventOptions): Promise; + getScheduledEventUsers(eventID: string, options?: GetGuildScheduledEventUsersOptions): Promise; getTemplates(): Promise; getVanity(): Promise; getVoiceRegions(): Promise; @@ -2868,20 +2907,21 @@ declare namespace Eris { permissionsOf(memberID: string | Member | MemberRoles): Permission; } - export class GuildScheduledEvent extends Base { - channelID: string; + export class GuildScheduledEvent extends Base { + channelID: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? null : PossiblyUncachedSpeakableChannel; + creator?: User; description?: string; entityID: string; - entityMetadata: GuildScheduledEventMetadata; - entityType: GuildScheduledEventEntityTypes; - guildID: string; + entityMetadata: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? Required : null; + entityType: T; + guild: PossiblyUncachedGuild; id: string; + image?: string; name: string; privacyLevel: GuildScheduledEventPrivacyLevel; - scheduledEndTime: number; + scheduledEndTime: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? number : number | null; scheduledStartTime: number; status: GuildScheduledEventStatus; - creator?: User; userCount?: number; delete(): Promise; edit(event: GuildScheduledEventEditOptions): Promise; diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 1550f6710..05c1fd59b 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -463,7 +463,7 @@ class Guild extends Base { * @arg {String} event.privacyLevel The privacy level of the event * @arg {Date} [event.scheduledEndTime] The time when the event is scheduled to end. This is required if `entityType` is `3` (external) * @arg {Date} event.scheduledStartTime The time the event will start - * @returns {Promise} + * @returns {Promise} */ createScheduledEvent(event) { return this._client.createGuildScheduledEvent.call(this._client, this.id, event); @@ -1019,15 +1019,6 @@ class Guild extends Base { return this._client.getRESTGuildEmojis.call(this._client, this.id); } - /** - * Get a guild scheduled event data via the REST API. REST mode is required to use this endpoint. - * @arg {String} eventID The id of the event - * @returns {Promise} - */ - getRESTEvent(eventID) { - return this._client.getRESTGuildScheduledEvent.call(this._client, this.id, eventID); - } - /** * Get a guild's members via the REST API. REST mode is required to use this endpoint. * @arg {String} memberID The ID of the member From e0ebb13261a59c46d3191170d25d21a4fcbcb2db Mon Sep 17 00:00:00 2001 From: bsian03 Date: Sat, 16 Apr 2022 00:23:58 +0100 Subject: [PATCH 65/70] Apply suggestions from code review Co-authored-by: HeadTriXz <32986761+HeadTriXz@users.noreply.github.com> --- index.d.ts | 8 +++----- lib/Client.js | 2 +- lib/rest/Endpoints.js | 2 +- lib/structures/Guild.js | 2 +- lib/structures/GuildScheduledEvent.js | 12 +++++++----- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/index.d.ts b/index.d.ts index 3804b4dc8..4dce0f8d5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2309,7 +2309,7 @@ declare namespace Eris { createGuild(name: string, options?: CreateGuildOptions): Promise; createGuildCommand(guildID: string, command: ApplicationCommandStructure): Promise; createGuildEmoji(guildID: string, options: EmojiOptions, reason?: string): Promise; - createGuildScheduledEvent(guildID: string, event: GuildScheduledEventOptions): Promise>; + createGuildScheduledEvent(guildID: string, event: GuildScheduledEventOptions, reason?: string): Promise>; createGuildFromTemplate(code: string, name: string, icon?: string): Promise; createGuildSticker(guildID: string, options: CreateStickerOptions, reason?: string): Promise; createGuildTemplate(guildID: string, name: string, description?: string | null): Promise; @@ -2369,7 +2369,7 @@ declare namespace Eris { options: { name?: string; roles?: string[] }, reason?: string ): Promise; - editGuildScheduledEvent(guildID: string, eventID: string, event: GuildScheduledEventEditOptions, reason: string): Promise>; + editGuildScheduledEvent(guildID: string, eventID: string, event: GuildScheduledEventEditOptions, reason?: string): Promise>; editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise; editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise; editGuildSticker(guildID: string, stickerID: string, options?: EditStickerOptions, reason?: string): Promise; @@ -2778,7 +2778,7 @@ declare namespace Eris { createChannel(name: string, type?: number, reason?: string, options?: CreateChannelOptions | string): Promise; createCommand(command: ApplicationCommandStructure): Promise; createEmoji(options: { image: string; name: string; roles?: string[] }, reason?: string): Promise; - createScheduledEvent(event: GuildScheduledEventOptions): Promise; + createScheduledEvent(event: GuildScheduledEventOptions, reason?: string): Promise>; createRole(options: RoleOptions | Role, reason?: string): Promise; createSticker(options: CreateStickerOptions, reason?: string): Promise; createTemplate(name: string, description?: string | null): Promise; @@ -2852,8 +2852,6 @@ declare namespace Eris { kickMember(userID: string, reason?: string): Promise; leave(): Promise; leaveVoiceChannel(): void; - listEvents(withUserCount: boolean): Promise>; - listEventUsers(eventID: string): void; permissionsOf(memberID: string | Member | MemberRoles): Permission; pruneMembers(options?: PruneMemberOptions): Promise; removeMemberRole(memberID: string, roleID: string, reason?: string): Promise; diff --git a/lib/Client.js b/lib/Client.js index ef2ec8bf0..f43ab669d 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -2508,7 +2508,7 @@ class Client extends EventEmitter { * @arg {String} [options.after] Get users after this user ID. If `options.before` is provided, this will be ignored. Fetching users in between `before` and `after` is not supported * @arg {String} [options.before] Get users before this user ID * @arg {Number} [options.limit=100] The number of users to get (max 100). Pagination will only work if one of `options.after` or `options.after` is also provided - * @arg {Boolean} [withMember] Include guild member data + * @arg {Boolean} [options.withMember] Include guild member data * @returns {Promise>} */ getGuildScheduledEventUsers(guildID, eventID, options = {}) { diff --git a/lib/rest/Endpoints.js b/lib/rest/Endpoints.js index 0299b9b3f..5bfcaf0fc 100644 --- a/lib/rest/Endpoints.js +++ b/lib/rest/Endpoints.js @@ -127,7 +127,7 @@ module.exports.DEFAULT_USER_AVATAR = (userDiscriminator) module.exports.GUILD_AVATAR = (guildID, userID, guildAvatar) => `/guilds/${guildID}/users/${userID}/avatars/${guildAvatar}`; module.exports.GUILD_DISCOVERY_SPLASH = (guildID, guildDiscoverySplash) => `/discovery-splashes/${guildID}/${guildDiscoverySplash}`; module.exports.GUILD_ICON = (guildID, guildIcon) => `/icons/${guildID}/${guildIcon}`; -module.exports.GUILD_SCHEDULED_EVENT_COVER = (eventID, eventIcon) => `guild-events/${eventID}/${eventIcon}`; +module.exports.GUILD_SCHEDULED_EVENT_COVER = (eventID, eventIcon) => `/guild-events/${eventID}/${eventIcon}`; module.exports.GUILD_SPLASH = (guildID, guildSplash) => `/splashes/${guildID}/${guildSplash}`; module.exports.ROLE_ICON = (roleID, roleIcon) => `/role-icons/${roleID}/${roleIcon}`; module.exports.TEAM_ICON = (teamID, teamIcon) => `/team-icons/${teamID}/${teamIcon}`; diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 05c1fd59b..45888bd72 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -1093,7 +1093,7 @@ class Guild extends Base { * @arg {String} [options.after] Get users after this user ID. If `options.before` is provided, this will be ignored. Fetching users in between `before` and `after` is not supported * @arg {String} [options.before] Get users before this user ID * @arg {Number} [options.limit=100] The number of users to get (max 100). Pagination will only work if one of `options.after` or `options.after` is also provided - * @arg {Boolean} [withMember] Include guild member data + * @arg {Boolean} [options.withMember] Include guild member data * @returns {Promise} */ getScheduledEventUsers(eventID, options) { diff --git a/lib/structures/GuildScheduledEvent.js b/lib/structures/GuildScheduledEvent.js index c018aa439..24255a6b7 100644 --- a/lib/structures/GuildScheduledEvent.js +++ b/lib/structures/GuildScheduledEvent.js @@ -33,7 +33,9 @@ class GuildScheduledEvent extends Base { } else { this.creator = null; } - this.guild = client.guilds.get(data.guild_id) || {id: data.guild_id}; + this.guild = client.guilds.get(data.guild_id) || { + id: data.guild_id + }; this.scheduledEndTime = null; this.update(data); } @@ -75,7 +77,7 @@ class GuildScheduledEvent extends Base { this.entityID = data.entity_id; } if(data.entity_metadata !== undefined) { - this.entityMetadata = {location: data.location}; + this.entityMetadata = data.entity_metadata; } if(data.user_count !== undefined) { this.userCount = data.user_count; @@ -114,8 +116,8 @@ class GuildScheduledEvent extends Base { * @arg {String} [reason] The reason to be displayed in audit logs * @returns {Promise} */ - edit(event) { - return this._client.editGuildScheduledEvent.call(this._client, this.guildID, this.id, event); + edit(event, reason) { + return this._client.editGuildScheduledEvent.call(this._client, this.guildID, this.id, event, reason); } /** @@ -124,7 +126,7 @@ class GuildScheduledEvent extends Base { * @arg {String} [options.after] Get users after this user ID. If `options.before` is provided, this will be ignored. Fetching users in between `before` and `after` is not supported * @arg {String} [options.before] Get users before this user ID * @arg {Number} [options.limit=100] The number of users to get (max 100). Pagination will only work if one of `options.after` or `options.after` is also provided - * @arg {Boolean} [withMember] Include guild member data + * @arg {Boolean} [options.withMember] Include guild member data * @returns {Promise>} */ getUsers(options) { From 98314d2864474856a48e36eb285b10d3f7b443ee Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 16 Apr 2022 00:31:55 +0100 Subject: [PATCH 66/70] Apply suggestions from code review --- index.d.ts | 12 ++++++------ lib/Client.js | 6 ++++-- lib/structures/Guild.js | 5 +++-- lib/structures/GuildScheduledEvent.js | 18 +++++++++--------- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/index.d.ts b/index.d.ts index 4dce0f8d5..740c9baab 100644 --- a/index.d.ts +++ b/index.d.ts @@ -619,9 +619,9 @@ declare namespace Eris { } interface OldGuildScheduledEvent { channel: PossiblyUncachedSpeakableChannel | null; - description?: string; - entityID?: string; - enitityMetadata?: GuildScheduledEventMetadata; + description?: string | null; + entityID: string | null; + enitityMetadata: GuildScheduledEventMetadata | null; entityType: GuildScheduledEventEntityTypes; image?: string; name: string; @@ -2909,7 +2909,7 @@ declare namespace Eris { channelID: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? null : PossiblyUncachedSpeakableChannel; creator?: User; description?: string; - entityID: string; + entityID: string | null; entityMetadata: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? Required : null; entityType: T; guild: PossiblyUncachedGuild; @@ -2922,8 +2922,8 @@ declare namespace Eris { status: GuildScheduledEventStatus; userCount?: number; delete(): Promise; - edit(event: GuildScheduledEventEditOptions): Promise; - listUsers(): void; + edit(event: GuildScheduledEventEditOptions, reason?: string): Promise; + getUsers(options?: GetGuildScheduledEventUsersOptions): Promise; } export class GuildIntegration extends Base { diff --git a/lib/Client.js b/lib/Client.js index f43ab669d..c0b194ebc 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -684,9 +684,10 @@ class Client extends EventEmitter { * @arg {String} event.privacyLevel The privacy level of the event * @arg {Date} [event.scheduledEndTime] The time when the event is scheduled to end. This is required if `entityType` is `3` (external) * @arg {Date} event.scheduledStartTime The time the event will start + * @arg {String} [reason] The reason to be displayed in audit logs * @returns {Promise} */ - createGuildScheduledEvent(guildID, event) { + createGuildScheduledEvent(guildID, event, reason) { return this.requestHandler.request("POST", Endpoints.GUILD_SCHEDULED_EVENTS(guildID), true, { channel_id: event.channelID, description: event.description, @@ -696,7 +697,8 @@ class Client extends EventEmitter { name: event.name, privacy_level: event.privacyLevel, scheduled_end_time: event.scheduledEndTime, - scheduled_start_time: event.scheduledStartTime + scheduled_start_time: event.scheduledStartTime, + reason: reason }).then((data) => new GuildScheduledEvent(data, this)); } diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 45888bd72..ee844117b 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -463,10 +463,11 @@ class Guild extends Base { * @arg {String} event.privacyLevel The privacy level of the event * @arg {Date} [event.scheduledEndTime] The time when the event is scheduled to end. This is required if `entityType` is `3` (external) * @arg {Date} event.scheduledStartTime The time the event will start + * @arg {String} [reason] The reason to be displayed in audit logs * @returns {Promise} */ - createScheduledEvent(event) { - return this._client.createGuildScheduledEvent.call(this._client, this.id, event); + createScheduledEvent(event, reason) { + return this._client.createGuildScheduledEvent.call(this._client, this.id, event, reason); } /** diff --git a/lib/structures/GuildScheduledEvent.js b/lib/structures/GuildScheduledEvent.js index 24255a6b7..055b25d8d 100644 --- a/lib/structures/GuildScheduledEvent.js +++ b/lib/structures/GuildScheduledEvent.js @@ -135,18 +135,18 @@ class GuildScheduledEvent extends Base { toJSON(props = []) { return super.toJSON([ - "guildID", - "channelID", - "name", + "channel", + "creator", "description", - "scheduledStartTime", - "scheduledEndTime", - "privacyLevel", - "status", - "entityType", "entityID", "entityMetadata", - "creator", + "entityType", + "guild", + "name", + "privacyLevel", + "scheduledEndTime", + "scheduledStartTime", + "status", "userCount", ...props ]); From a0e55e7cbb3c9fe0352c8ce0e4a9058b9e0aa8be Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 10 May 2022 14:51:30 +0100 Subject: [PATCH 67/70] Fix types i hope --- index.d.ts | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/index.d.ts b/index.d.ts index 740c9baab..3826ea4c2 100644 --- a/index.d.ts +++ b/index.d.ts @@ -88,6 +88,8 @@ declare namespace Eris { type DefaultNotifications = Constants["DefaultMessageNotificationLevels"][keyof Constants["DefaultMessageNotificationLevels"]]; type ExplicitContentFilter = Constants["ExplicitContentFilterLevels"][keyof Constants["ExplicitContentFilterLevels"]]; type GuildFeatures = Constants["GuildFeatures"][number]; + type GuildScheduledEventEditOptions = GuildScheduledEventEditOptionsExternal | GuildScheduledEventEditOptionsDiscord | GuildScheduledEventEditOptionsBase; + type GuildScheduledEventOptions = GuildScheduledEventOptionsExternal | GuildScheduledEventOptionsDiscord | GuildScheduledEventOptionsBase; type GuildScheduledEventEntityTypes = Constants["GuildScheduledEventEntityTypes"][keyof Constants["GuildScheduledEventEntityTypes"]]; type GuildScheduledEventPrivacyLevel = Constants["GuildScheduledEventPrivacyLevel"][keyof Constants["GuildScheduledEventPrivacyLevel"]]; type GuildScheduledEventStatus = Constants["GuildScheduledEventStatus"][keyof Constants["GuildScheduledEventStatus"]]; @@ -935,26 +937,44 @@ declare namespace Eris { interface GuildScheduledEventMetadata { location?: string; } - interface GuildScheduledEventEditOptions { - channelID: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? null | undefined : string | undefined; + interface GuildScheduledEventEditOptionsBase { + channelID?: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? null : string; description?: string | null; - entityMetadata: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? Required : GuildScheduledEventMetadata | null | undefined; + entityMetadata?: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? Required : GuildScheduledEventMetadata | null; entityType?: T; image?: string; name?: string; privacyLevel?: GuildScheduledEventPrivacyLevel; - scheduledEndTime: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? Date : Date | undefined + scheduledEndTime?: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? Date : Date | undefined; scheduledStartTime?: Date; status?: GuildScheduledEventStatus; } - interface GuildScheduledEventOptions extends Omit, "status"> { - channelID: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? undefined : string; - entityMetadata: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? Required : GuildScheduledEventMetadata | undefined; + interface GuildScheduledEventEditOptionsDiscord extends GuildScheduledEventEditOptionsBase> { + channelID: string; + entityMetadata: GuildScheduledEventMetadata + } + interface GuildScheduledEventEditOptionsExternal extends GuildScheduledEventEditOptionsBase { + channelID: null; + enitityMetadata: Required; + scheduledEndTime: Date; + } + interface GuildScheduledEventOptionsBase extends Omit, "entityMetadata" | "status"> { + channelID: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? never : string; + entityMetadata?: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? Required : GuildScheduledEventMetadata | undefined; entityType: T; name: string; privacyLevel: GuildScheduledEventPrivacyLevel; scheduledStartTime: Date; } + interface GuildScheduledEventOptionsDiscord extends GuildScheduledEventEditOptionsBase> { + channelID: string; + entityMetadata: GuildScheduledEventMetadata; + } + interface GuildScheduledEventOptionsExternal extends GuildScheduledEventOptionsBase { + channelID: never; + enitityMetadata: Required; + scheduledEndTime: Date; + } interface GuildScheduledEventUser { guildScheduledEventID: string; user: User; @@ -2922,7 +2942,7 @@ declare namespace Eris { status: GuildScheduledEventStatus; userCount?: number; delete(): Promise; - edit(event: GuildScheduledEventEditOptions, reason?: string): Promise; + edit(event: GuildScheduledEventEditOptions, reason?: string): Promise>; getUsers(options?: GetGuildScheduledEventUsersOptions): Promise; } From dea37f08f67a3e0365c329595c92b0f34b443cec Mon Sep 17 00:00:00 2001 From: Donovan Daniels Date: Tue, 7 Jun 2022 00:15:50 -0500 Subject: [PATCH 68/70] lint ts --- index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.d.ts b/index.d.ts index d278d69aa..e1a6052cd 100644 --- a/index.d.ts +++ b/index.d.ts @@ -963,7 +963,7 @@ declare namespace Eris { } interface GuildScheduledEventEditOptionsDiscord extends GuildScheduledEventEditOptionsBase> { channelID: string; - entityMetadata: GuildScheduledEventMetadata + entityMetadata: GuildScheduledEventMetadata; } interface GuildScheduledEventEditOptionsExternal extends GuildScheduledEventEditOptionsBase { channelID: null; @@ -2341,8 +2341,8 @@ declare namespace Eris { createGuild(name: string, options?: CreateGuildOptions): Promise; createGuildCommand(guildID: string, command: ApplicationCommandStructure): Promise; createGuildEmoji(guildID: string, options: EmojiOptions, reason?: string): Promise; - createGuildScheduledEvent(guildID: string, event: GuildScheduledEventOptions, reason?: string): Promise>; createGuildFromTemplate(code: string, name: string, icon?: string): Promise; + createGuildScheduledEvent(guildID: string, event: GuildScheduledEventOptions, reason?: string): Promise>; createGuildSticker(guildID: string, options: CreateStickerOptions, reason?: string): Promise; createGuildTemplate(guildID: string, name: string, description?: string | null): Promise; createInteractionResponse(interactionID: string, interactionToken: string, options: InteractionOptions, file?: FileContent | FileContent[]): Promise; @@ -2360,8 +2360,8 @@ declare namespace Eris { deleteGuildCommand(guildID: string, commandID: string): Promise; deleteGuildDiscoverySubcategory(guildID: string, categoryID: string, reason?: string): Promise; deleteGuildEmoji(guildID: string, emojiID: string, reason?: string): Promise; - deleteGuildScheduledEvent(guildID: string, eventID: string): Promise; deleteGuildIntegration(guildID: string, integrationID: string): Promise; + deleteGuildScheduledEvent(guildID: string, eventID: string): Promise; deleteGuildSticker(guildID: string, stickerID: string, reason?: string): Promise; deleteGuildTemplate(guildID: string, code: string): Promise; deleteInvite(inviteID: string, reason?: string): Promise; @@ -2402,9 +2402,9 @@ declare namespace Eris { options: { name?: string; roles?: string[] }, reason?: string ): Promise; - editGuildScheduledEvent(guildID: string, eventID: string, event: GuildScheduledEventEditOptions, reason?: string): Promise>; editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise; editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise; + editGuildScheduledEvent(guildID: string, eventID: string, event: GuildScheduledEventEditOptions, reason?: string): Promise>; editGuildSticker(guildID: string, stickerID: string, options?: EditStickerOptions, reason?: string): Promise; editGuildTemplate(guildID: string, code: string, options: GuildTemplateOptions): Promise; editGuildVanity(guildID: string, code: string | null): Promise; @@ -2508,7 +2508,6 @@ declare namespace Eris { getRESTGuildChannels(guildID: string): Promise; getRESTGuildEmoji(guildID: string, emojiID: string): Promise; getRESTGuildEmojis(guildID: string): Promise; - getRESTGuildScheduledEvent(guildID: string, eventID: string, options?: GetGuildScheduledEventOptions): Promise; getRESTGuildMember(guildID: string, memberID: string): Promise; getRESTGuildMembers(guildID: string, options?: GetRESTGuildMembersOptions): Promise; /** @deprecated */ @@ -2517,6 +2516,7 @@ declare namespace Eris { getRESTGuilds(options?: GetRESTGuildsOptions): Promise; /** @deprecated */ getRESTGuilds(limit?: number, before?: string, after?: string): Promise; + getRESTGuildScheduledEvent(guildID: string, eventID: string, options?: GetGuildScheduledEventOptions): Promise; getRESTGuildSticker(guildID: string, stickerID: string): Promise; getRESTGuildStickers(guildID: string): Promise; getRESTSticker(stickerID: string): Promise; @@ -2813,9 +2813,9 @@ declare namespace Eris { createChannel(name: string, type?: number, reason?: string, options?: CreateChannelOptions | string): Promise; createCommand(command: ApplicationCommandStructure): Promise; createEmoji(options: { image: string; name: string; roles?: string[] }, reason?: string): Promise; - createScheduledEvent(event: GuildScheduledEventOptions, reason?: string): Promise>; createRole(options: RoleOptions, reason?: string): Promise; createRole(options: Role, reason?: string): Promise; + createScheduledEvent(event: GuildScheduledEventOptions, reason?: string): Promise>; createSticker(options: CreateStickerOptions, reason?: string): Promise; createTemplate(name: string, description?: string | null): Promise; delete(): Promise; From fe09b0d8b710b6767fb055b2f2083c13403d8921 Mon Sep 17 00:00:00 2001 From: Donovan Daniels Date: Tue, 7 Jun 2022 00:16:40 -0500 Subject: [PATCH 69/70] remove trailing comma --- esm.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esm.mjs b/esm.mjs index b30ff660f..b250cead8 100644 --- a/esm.mjs +++ b/esm.mjs @@ -60,5 +60,5 @@ export const { VoiceChannel, VoiceConnection, VoiceConnectionManager, - VoiceState, + VoiceState } = Eris; From 842ccd01f39fc99b629dbef09d2d0e67457fb601 Mon Sep 17 00:00:00 2001 From: Donovan Daniels Date: Tue, 7 Jun 2022 00:18:39 -0500 Subject: [PATCH 70/70] recalculate perms --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index e1a6052cd..7ceb00e13 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1902,9 +1902,9 @@ declare namespace Eris { startEmbeddedActivities: 549755813888n; moderateMembers: 1099511627776n; allGuild: 1110182461630n; - allText: 518349388881n; + allText: 535529258065n; allVoice: 554385278737n; - all: 2181843386367n; + all: 2199023255551n; }; PremiumTiers: { NONE: 0;