fix(handlers/channel): handle max_age and max_uses limit in createInvite() (#597)

* fix: handle invalid invite create limits

* refactor: cleanup conditonals

* chore: clarification

Co-authored-by: ayntee <ayyantee@gmail.com>
This commit is contained in:
Skillz4Killz
2021-03-06 14:44:31 -05:00
committed by GitHub
parent e5bf5cd47c
commit d084c3f3c4
2 changed files with 19 additions and 4 deletions
+14
View File
@@ -321,6 +321,20 @@ export async function createInvite(
throw new Error(Errors.MISSING_CREATE_INSTANT_INVITE);
}
if (options.max_age && (options.max_age > 604800 || options.max_age < 0)) {
console.log(
`The max age for invite created in ${channelID} was not between 0-604800. Using default values instead.`,
);
options.max_age = undefined;
}
if (options.max_uses && (options.max_uses > 100 || options.max_uses < 0)) {
console.log(
`The max uses for invite created in ${channelID} was not between 0-100. Using default values instead.`,
);
options.max_uses = undefined;
}
const result = await RequestManager.post(
endpoints.CHANNEL_INVITES(channelID),
options,