feat: add Invite#delete() method

This commit is contained in:
ayntee 2020-12-25 20:44:05 +04:00
parent 3695b81de6
commit e919ad38de

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