From e919ad38de50c2b2b6090a133637738236b6b22d Mon Sep 17 00:00:00 2001 From: ayntee Date: Fri, 25 Dec 2020 20:44:05 +0400 Subject: [PATCH] feat: add Invite#delete() method --- src/structures/invite.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/structures/invite.ts b/src/structures/invite.ts index 59d172d..f27f841 100644 --- a/src/structures/invite.ts +++ b/src/structures/invite.ts @@ -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 { + 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