mirror of
https://github.com/danbulant/discord.js
synced 2026-07-07 20:20:55 +00:00
feat(Invite): add deletable getter (#3203)
* add Invite#deletable * fix ci * reee * since guild is nullable * accommodate for external invites * nit(Invite): use guild instead of channel.guild
This commit is contained in:
parent
f7f4607b5f
commit
c4b79571ba
2 changed files with 15 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Endpoints } = require('../util/Constants');
|
const { Endpoints } = require('../util/Constants');
|
||||||
|
const Permissions = require('../util/Permissions');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -91,6 +92,18 @@ class Invite extends Base {
|
||||||
return this.createdTimestamp ? new Date(this.createdTimestamp) : null;
|
return this.createdTimestamp ? new Date(this.createdTimestamp) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the invite is deletable by the client user
|
||||||
|
* @type {boolean}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get deletable() {
|
||||||
|
const guild = this.guild;
|
||||||
|
if (!guild || !this.client.guilds.has(guild.id)) return false;
|
||||||
|
return this.channel.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_CHANNELS, false) ||
|
||||||
|
guild.me.permissions.has(Permissions.FLAGS.MANAGE_GUILD);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The timestamp the invite will expire at
|
* The timestamp the invite will expire at
|
||||||
* @type {?number}
|
* @type {?number}
|
||||||
|
|
|
||||||
3
typings/index.d.ts
vendored
3
typings/index.d.ts
vendored
|
|
@ -615,7 +615,8 @@ declare module 'discord.js' {
|
||||||
constructor(client: Client, data: object);
|
constructor(client: Client, data: object);
|
||||||
public channel: GuildChannel;
|
public channel: GuildChannel;
|
||||||
public code: string;
|
public code: string;
|
||||||
public readonly createdAt: Date;
|
public readonly deletable: boolean;
|
||||||
|
public readonly createdAt: Date | null;
|
||||||
public createdTimestamp: number | null;
|
public createdTimestamp: number | null;
|
||||||
public readonly expiresAt: Date | null;
|
public readonly expiresAt: Date | null;
|
||||||
public readonly expiresTimestamp: number | null;
|
public readonly expiresTimestamp: number | null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue