-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Guild): add api methods for membership screening #5144
Conversation
src/structures/Guild.js
Outdated
let formFields = []; | ||
for (const field of res.form_fields) { | ||
formFields.push({ | ||
fieldType: field.field_type, | ||
label: field.label, | ||
values: field.values, | ||
required: field.required, | ||
}); | ||
} | ||
return { | ||
enabled: this.membershipScreeningEnabled, | ||
description: res.description, | ||
formFields: formFields, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems this code is duplicated, in any case the same as before this can use the map
function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that there was a few instances of this necessary, would it be desirable to have a private function that transforms this data and call that in each location instead?
update: upstream discord/discord-api-docs#2396 has been merged and finalized |
* remove utility method * clarify types * add error message * better example - advatih
if (!this.features.includes('COMMUNITY')) { | ||
throw new Error('COMMUNITY'); | ||
} | ||
const data = await this.client.api.guilds(this.id)['member-verification'].get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discord responds with a 204 if membership screening is not yet set up.
(data
will be an empty buffer then, causing an error to be thrown when trying to map the undefined form_fields)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be a bug with how the API is currently handling this, see discord/discord-api-docs#2530
A check is still a good idea though, will add.
@@ -1422,6 +1470,45 @@ class Guild extends Base { | |||
.then(() => this); | |||
} | |||
|
|||
/** | |||
* A `Partial` object is a representation of any existing object. | |||
* This object contains between 1 and all of the original objects parameters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you actually can edit with an empty object.
* This object contains between 1 and all of the original objects parameters. | |
* This object contains between 0 and all of the original objects parameters. |
Looks like the associated API methods for this are being changed, I'll draft this PR until we get the updated ones. |
If this is still wanted (upstream PR has been merged) this should be undrafted and rebased. |
@iCrawl the docs were removed pending breaking changes (see previous comment), and Discord hasn't given any information since then |
Right, I didn't check, I assumed that would be the "new" PR. Thats fine then. |
if (!this.features.includes('COMMUNITY')) { | ||
throw new Error('COMMUNITY'); | ||
} | ||
const data = await this.client.api.guilds(this.id)['member-verification'].get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const data = await this.client.api.guilds(this.id)['member-verification'].get(); | |
const data = await this.client.api.guilds(this.id, 'member-verification').get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll address this when I can resume work on this PR.
Please describe the changes this PR makes and why it should be merged:
Ref: discord/discord-api-docs#2396
A similar PR is coming to do the same with the Guild Welcome Screen
Status
Semantic versioning classification: