From 30724dc7918d71e5aa2ecb0fa275f5e196189572 Mon Sep 17 00:00:00 2001 From: ayntee Date: Fri, 25 Dec 2020 16:22:10 +0400 Subject: [PATCH 01/20] fix: add permissions field to InteractionPayload#member --- src/types/slash.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/types/slash.ts b/src/types/slash.ts index d48f363..a88622a 100644 --- a/src/types/slash.ts +++ b/src/types/slash.ts @@ -32,7 +32,10 @@ export interface InteractionPayload { /** Token of the Interaction to respond */ token: string /** Member object of user who invoked */ - member: MemberPayload + member: MemberPayload & { + /** Total permissions of the member in the channel, including overrides */ + permissions: string + } /** ID of the Interaction */ id: string /** From 6e8af1f7dacf16276e8cd29871c03a26c7470dd8 Mon Sep 17 00:00:00 2001 From: Radoslaw Partyka Date: Fri, 1 Jan 2021 16:27:30 +0100 Subject: [PATCH 02/20] Removing redundant code from guild struct --- src/structures/guild.ts | 42 +---------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/src/structures/guild.ts b/src/structures/guild.ts index 730c143..bda4762 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -163,9 +163,8 @@ export class Guild extends Base { constructor(client: Client, data: GuildPayload) { super(client, data) - this.id = data.id + this.readFromData(data) this.bans = new GuildBans(client, this) - this.unavailable = data.unavailable this.members = new MembersManager(this.client, this) this.voiceStates = new GuildVoiceStatesManager(client, this) this.presences = new GuildPresencesManager(client, this) @@ -177,45 +176,6 @@ export class Guild extends Base { this.roles = new RolesManager(this.client, this) this.emojis = new GuildEmojisManager(this.client, this.client.emojis, this) this.invites = new InviteManager(this.client, this) - - if (!this.unavailable) { - this.name = data.name - this.icon = data.icon - this.iconHash = data.icon_hash - this.splash = data.splash - this.discoverySplash = data.discovery_splash - this.owner = data.owner - this.ownerID = data.owner_id - this.permissions = data.permissions - this.region = data.region - this.afkTimeout = data.afk_timeout - this.afkChannelID = data.afk_channel_id - this.widgetEnabled = data.widget_enabled - this.widgetChannelID = data.widget_channel_id - this.verificationLevel = data.verification_level - this.defaultMessageNotifications = data.default_message_notifications - this.explicitContentFilter = data.explicit_content_filter - this.features = data.features - this.mfaLevel = data.mfa_level - this.systemChannelID = data.system_channel_id - this.systemChannelFlags = data.system_channel_flags - this.rulesChannelID = data.rules_channel_id - this.joinedAt = data.joined_at - this.large = data.large - this.memberCount = data.member_count - this.maxPresences = data.max_presences - this.maxMembers = data.max_members - this.vanityURLCode = data.vanity_url_code - this.description = data.description - this.banner = data.banner - this.premiumTier = data.premium_tier - this.premiumSubscriptionCount = data.premium_subscription_count - this.preferredLocale = data.preferred_locale - this.publicUpdatesChannelID = data.public_updates_channel_id - this.maxVideoChannelUsers = data.max_video_channel_users - this.approximateNumberCount = data.approximate_number_count - this.approximatePresenceCount = data.approximate_presence_count - } } readFromData(data: GuildPayload): void { From c322c25fb03748f34c324d45bf930692cc8c2942 Mon Sep 17 00:00:00 2001 From: Radoslaw Partyka Date: Fri, 1 Jan 2021 16:54:33 +0100 Subject: [PATCH 03/20] awaitAvailability in guild struct --- src/structures/guild.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/structures/guild.ts b/src/structures/guild.ts index bda4762..be7eaf3 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -290,6 +290,24 @@ export class Guild extends Base { resolve(this) }) } + + /** + * Fulfills promise when guild becomes available + * @param delay the delay between checking guild availability + */ + async awaitAvailiable( + delay: number = 1000 + ): Promise { + const promise1 = new Promise((resolve, reject) => { + while(true) { + await new Promise(reso => setTimeout(reso, delay)) + if(!this.unavailable) { + resolve() + break; + } + } + }); + } } export class GuildIntegration extends Base { From 6c3f71669d7ff42fcede121de5a7848e89c664ad Mon Sep 17 00:00:00 2001 From: Radoslaw Partyka Date: Fri, 1 Jan 2021 16:55:27 +0100 Subject: [PATCH 04/20] awaitAvailability is awaitAvailability now instead of awaitAvailiable --- src/structures/guild.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/guild.ts b/src/structures/guild.ts index be7eaf3..cbc9aef 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -295,7 +295,7 @@ export class Guild extends Base { * Fulfills promise when guild becomes available * @param delay the delay between checking guild availability */ - async awaitAvailiable( + async awaitAvailability( delay: number = 1000 ): Promise { const promise1 = new Promise((resolve, reject) => { From 055a030c4e9e465291e39d22cfbe68c9b53b09c1 Mon Sep 17 00:00:00 2001 From: Radoslaw Partyka Date: Fri, 1 Jan 2021 17:09:41 +0100 Subject: [PATCH 05/20] Code / style fixes --- src/structures/guild.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/structures/guild.ts b/src/structures/guild.ts index cbc9aef..5645bf0 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -163,6 +163,8 @@ export class Guild extends Base { constructor(client: Client, data: GuildPayload) { super(client, data) + this.id = data.id + this.unavailable = data.unavailable this.readFromData(data) this.bans = new GuildBans(client, this) this.members = new MembersManager(this.client, this) @@ -298,15 +300,12 @@ export class Guild extends Base { async awaitAvailability( delay: number = 1000 ): Promise { - const promise1 = new Promise((resolve, reject) => { while(true) { - await new Promise(reso => setTimeout(reso, delay)) + await new Promise(resolve => setTimeout(resolve, delay)) if(!this.unavailable) { - resolve() - break; + return; } - } - }); + } } } From cff738b2e9cc16ca36304e3894e7983ed984a773 Mon Sep 17 00:00:00 2001 From: DjDeveloper <43033058+DjDeveloperr@users.noreply.github.com> Date: Sat, 2 Jan 2021 08:14:16 +0530 Subject: [PATCH 06/20] feat: add CNAME --- CNAME | 1 + 1 file changed, 1 insertion(+) create mode 100644 CNAME diff --git a/CNAME b/CNAME new file mode 100644 index 0000000..9a40703 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +harmony.mod.land From 39c7761a962fb0070fa264de46fee06e37d613d6 Mon Sep 17 00:00:00 2001 From: DjDeveloper <43033058+DjDeveloperr@users.noreply.github.com> Date: Sat, 2 Jan 2021 08:14:52 +0530 Subject: [PATCH 07/20] feat: delete cname --- CNAME | 1 - 1 file changed, 1 deletion(-) delete mode 100644 CNAME diff --git a/CNAME b/CNAME deleted file mode 100644 index 9a40703..0000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ -harmony.mod.land From e009ae3127139aaca285f7e23f15981404f04120 Mon Sep 17 00:00:00 2001 From: ZiomaleQ Date: Tue, 5 Jan 2021 14:10:16 +0100 Subject: [PATCH 08/20] rewriting awaitAvailability --- src/structures/guild.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/structures/guild.ts b/src/structures/guild.ts index f725189..414f355 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -310,14 +310,17 @@ export class Guild extends Base { * Fulfills promise when guild becomes available * @param delay the delay between checking guild availability */ - async awaitAvailability( - delay: number = 1000 - ): Promise { - while(true) { - await new Promise(resolve => setTimeout(resolve, delay)) - if(!this.unavailable) { - return; - } + async awaitAvailability(delay: number = 1000): Promise { + if(!this.unavailable) return; + var loaded = false; + var listener = (guild: Guild) => loaded = loaded || guild.id == this.id; + this.client.on('guildLoaded', listener); + while(true) { + await new Promise(resolve => setTimeout(resolve, delay)); + if(loaded) { + this.client.removeListener('guildLoaded', listener); + return; + } } } } From 4364d3879b397f72f02be786646f22132c0bef8f Mon Sep 17 00:00:00 2001 From: ZiomaleQ Date: Tue, 5 Jan 2021 14:12:21 +0100 Subject: [PATCH 09/20] Code fix to match requirements --- src/structures/guild.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/guild.ts b/src/structures/guild.ts index 414f355..a2657d9 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -313,7 +313,7 @@ export class Guild extends Base { async awaitAvailability(delay: number = 1000): Promise { if(!this.unavailable) return; var loaded = false; - var listener = (guild: Guild) => loaded = loaded || guild.id == this.id; + var listener = (guild: Guild) => loaded = loaded || guild.id === this.id; this.client.on('guildLoaded', listener); while(true) { await new Promise(resolve => setTimeout(resolve, delay)); From c4a3fbc45cd00bc097522f4abe3e5f263505a766 Mon Sep 17 00:00:00 2001 From: ZiomaleQ Date: Tue, 5 Jan 2021 14:14:24 +0100 Subject: [PATCH 10/20] Code fix #2, requirements again --- src/structures/guild.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/guild.ts b/src/structures/guild.ts index a2657d9..5081fcf 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -313,7 +313,7 @@ export class Guild extends Base { async awaitAvailability(delay: number = 1000): Promise { if(!this.unavailable) return; var loaded = false; - var listener = (guild: Guild) => loaded = loaded || guild.id === this.id; + var listener = (guild: Guild): void => { loaded = loaded || guild.id === this.id }; this.client.on('guildLoaded', listener); while(true) { await new Promise(resolve => setTimeout(resolve, delay)); From 6b5c15d19af659c6c1010e85b8894e729004c4d3 Mon Sep 17 00:00:00 2001 From: ZiomaleQ Date: Tue, 5 Jan 2021 14:42:27 +0100 Subject: [PATCH 11/20] event based await in guildAvailability method --- src/structures/guild.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/structures/guild.ts b/src/structures/guild.ts index 5081fcf..04ebcfe 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -311,16 +311,15 @@ export class Guild extends Base { * @param delay the delay between checking guild availability */ async awaitAvailability(delay: number = 1000): Promise { - if(!this.unavailable) return; - var loaded = false; - var listener = (guild: Guild): void => { loaded = loaded || guild.id === this.id }; - this.client.on('guildLoaded', listener); - while(true) { - await new Promise(resolve => setTimeout(resolve, delay)); - if(loaded) { - this.client.removeListener('guildLoaded', listener); - return; - } + return await new Promise((resolve, reject) => { + if(!this.unavailable) return; + var listener = (guild: Guild): void => { + if (guild.id === this.id) { + this.removeListener('guildLoaded', listener); + resolve(); + } + }; + this.client.on('guildLoaded', listener); } } } From 60164122bf169b864f00e89f086c2ad0bddbd9bc Mon Sep 17 00:00:00 2001 From: ZiomaleQ Date: Tue, 5 Jan 2021 14:51:04 +0100 Subject: [PATCH 12/20] Adding promise ending ')' --- src/structures/guild.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/structures/guild.ts b/src/structures/guild.ts index 04ebcfe..c1af7ca 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -313,14 +313,14 @@ export class Guild extends Base { async awaitAvailability(delay: number = 1000): Promise { return await new Promise((resolve, reject) => { if(!this.unavailable) return; - var listener = (guild: Guild): void => { + let listener = (guild: Guild): void => { if (guild.id === this.id) { - this.removeListener('guildLoaded', listener); + this.client.removeListener('guildLoaded', listener); resolve(); } }; this.client.on('guildLoaded', listener); - } + }); } } From 734133bccabf423e0ed68678300ff700b34b2260 Mon Sep 17 00:00:00 2001 From: ZiomaleQ Date: Tue, 5 Jan 2021 14:53:00 +0100 Subject: [PATCH 13/20] Code fix #3, requirements again --- src/structures/guild.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/guild.ts b/src/structures/guild.ts index c1af7ca..83db58d 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -313,7 +313,7 @@ export class Guild extends Base { async awaitAvailability(delay: number = 1000): Promise { return await new Promise((resolve, reject) => { if(!this.unavailable) return; - let listener = (guild: Guild): void => { + const listener = (guild: Guild): void => { if (guild.id === this.id) { this.client.removeListener('guildLoaded', listener); resolve(); From fbd6eae2446c621edd851b67f2e615faa6ab75d9 Mon Sep 17 00:00:00 2001 From: ZiomaleQ Date: Tue, 5 Jan 2021 16:24:56 +0100 Subject: [PATCH 14/20] deleting unused function parameter --- src/structures/guild.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/structures/guild.ts b/src/structures/guild.ts index 83db58d..9415747 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -308,9 +308,8 @@ export class Guild extends Base { /** * Fulfills promise when guild becomes available - * @param delay the delay between checking guild availability */ - async awaitAvailability(delay: number = 1000): Promise { + async awaitAvailability(): Promise { return await new Promise((resolve, reject) => { if(!this.unavailable) return; const listener = (guild: Guild): void => { From 2fadcfa4079c1d24b35b30d494b4e998501453b0 Mon Sep 17 00:00:00 2001 From: ZiomaleQ Date: Tue, 5 Jan 2021 16:27:03 +0100 Subject: [PATCH 15/20] awaitAvailability function returns Promise now --- src/structures/guild.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/structures/guild.ts b/src/structures/guild.ts index 9415747..771eea0 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -309,13 +309,13 @@ export class Guild extends Base { /** * Fulfills promise when guild becomes available */ - async awaitAvailability(): Promise { + async awaitAvailability(): Promise { return await new Promise((resolve, reject) => { if(!this.unavailable) return; const listener = (guild: Guild): void => { if (guild.id === this.id) { this.client.removeListener('guildLoaded', listener); - resolve(); + resolve(this); } }; this.client.on('guildLoaded', listener); From 53b49e45aa39dac3b23ebbd61c5e1da1052bd5fb Mon Sep 17 00:00:00 2001 From: Aki <71239005+AkiaCode@users.noreply.github.com> Date: Wed, 6 Jan 2021 12:38:42 +0900 Subject: [PATCH 16/20] Hello, 2021 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 585d405..4c76c14 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,6 @@ Small note: If editing the README, please conform to the [standard-readme](https ## License -[MIT © 2020 Harmony Org](LICENSE) +[MIT © 2020-2021 Harmony Org](LICENSE) #### Made with ❤ by Harmony-org From 3fe0001e4434cc9c22ecccc92243b265ea1528b1 Mon Sep 17 00:00:00 2001 From: Aki <71239005+AkiaCode@users.noreply.github.com> Date: Wed, 6 Jan 2021 12:39:17 +0900 Subject: [PATCH 17/20] feat(LICENSE) --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index c52f6d0..3571813 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Harmony Org +Copyright (c) 2020-2021 Harmony Org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 1d562f6997801d86e109d93d607f4567eea71498 Mon Sep 17 00:00:00 2001 From: ZiomaleQ Date: Thu, 7 Jan 2021 11:08:37 +0100 Subject: [PATCH 18/20] adding timeout to awaitAvailability --- src/structures/guild.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/structures/guild.ts b/src/structures/guild.ts index 771eea0..4fe7f9c 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -308,10 +308,11 @@ export class Guild extends Base { /** * Fulfills promise when guild becomes available + * @param timeout Configurable timeout to cancel the wait to safely remove listener. */ - async awaitAvailability(): Promise { + async awaitAvailability(timeout: number = 1000): Promise { return await new Promise((resolve, reject) => { - if(!this.unavailable) return; + if(!this.unavailable) resolve(this); const listener = (guild: Guild): void => { if (guild.id === this.id) { this.client.removeListener('guildLoaded', listener); @@ -319,6 +320,10 @@ export class Guild extends Base { } }; this.client.on('guildLoaded', listener); + setTimeout(() => { + this.client.removeListener('guildLoaded', listener); + reject(Error("Timeout. Guild didn't arrive in time.")); + }, timeout); }); } } From 68029084c4ecac798a5ed1f0c1d07428bda2b621 Mon Sep 17 00:00:00 2001 From: Aki <71239005+AkiaCode@users.noreply.github.com> Date: Sun, 10 Jan 2021 19:31:31 +0900 Subject: [PATCH 19/20] feat(LICENSE) --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 3571813..043f36c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020-2021 Harmony Org +Copyright (c) 2020-21 Harmony Org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From e3033b4cbf9a226c18968fc44333dc7ae283f0cd Mon Sep 17 00:00:00 2001 From: Aki <71239005+AkiaCode@users.noreply.github.com> Date: Sun, 10 Jan 2021 19:31:47 +0900 Subject: [PATCH 20/20] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c76c14..d2fe4c3 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,6 @@ Small note: If editing the README, please conform to the [standard-readme](https ## License -[MIT © 2020-2021 Harmony Org](LICENSE) +[MIT © 2020-21 Harmony Org](LICENSE) #### Made with ❤ by Harmony-org