Merge pull request #75 from ayntee/invite-methods

feat: add Invite#delete() method
This commit is contained in:
DjDeveloper 2020-12-26 08:15:09 +05:30 committed by GitHub
commit 523fc432e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import { Client } from '../models/client.ts'
import { ChannelPayload } from '../types/channel.ts'
import { INVITE } from '../types/endpoint.ts'
import { GuildPayload } from '../types/guild.ts'
import { InvitePayload } from '../types/invite.ts'
import { UserPayload } from '../types/user.ts'
@ -31,6 +32,12 @@ export class Invite extends Base {
this.approximatePresenceCount = data.approximate_presence_count
}
/** Delete an invite. Requires the MANAGE_CHANNELS permission on the channel this invite belongs to, or MANAGE_GUILD to remove any invite across the guild. Returns an invite object on success. Fires a Invite Delete Gateway event. */
async delete(): Promise<Invite> {
const res = await this.client.rest.delete(INVITE(this.code))
return new Invite(this.client, res)
}
readFromData(data: InvitePayload): void {
this.code = data.code ?? this.code
this.guild = data.guild ?? this.guild