mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
Add Invite.url and toString
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,5 +1,6 @@
|
||||
const PartialGuild = require('./PartialGuild');
|
||||
const PartialGuildChannel = require('./PartialGuildChannel');
|
||||
const Constants = require('../util/Constants');
|
||||
|
||||
/*
|
||||
{ max_age: 86400,
|
||||
@@ -110,6 +111,15 @@ class Invite {
|
||||
return new Date(this._createdAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* The URL to the invite
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
get url() {
|
||||
return Constants.Endpoints.inviteLink(this.code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes this invite
|
||||
* @returns {Promise<Invite>}
|
||||
@@ -117,6 +127,17 @@ class Invite {
|
||||
delete() {
|
||||
return this.client.rest.methods.deleteInvite(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* When concatenated with a string, this automatically concatenates the Invite's URL instead of the object.
|
||||
* @returns {string}
|
||||
* @example
|
||||
* // logs: Invite: https://discord.gg/A1b2C3
|
||||
* console.log(`Invite: ${invite}`);
|
||||
*/
|
||||
toString() {
|
||||
return this.url;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Invite;
|
||||
|
||||
@@ -76,6 +76,7 @@ const Endpoints = exports.Endpoints = {
|
||||
logout: `${API}/auth/logout`,
|
||||
gateway: `${API}/gateway`,
|
||||
invite: (id) => `${API}/invite/${id}`,
|
||||
inviteLink: (id) => `https://discord.gg/${id}`,
|
||||
CDN: 'https://cdn.discordapp.com',
|
||||
|
||||
// users
|
||||
|
||||
Reference in New Issue
Block a user