mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +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 PartialGuild = require('./PartialGuild');
|
||||||
const PartialGuildChannel = require('./PartialGuildChannel');
|
const PartialGuildChannel = require('./PartialGuildChannel');
|
||||||
|
const Constants = require('../util/Constants');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
{ max_age: 86400,
|
{ max_age: 86400,
|
||||||
@@ -110,6 +111,15 @@ class Invite {
|
|||||||
return new Date(this._createdAt);
|
return new Date(this._createdAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The URL to the invite
|
||||||
|
* @type {string}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get url() {
|
||||||
|
return Constants.Endpoints.inviteLink(this.code);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes this invite
|
* Deletes this invite
|
||||||
* @returns {Promise<Invite>}
|
* @returns {Promise<Invite>}
|
||||||
@@ -117,6 +127,17 @@ class Invite {
|
|||||||
delete() {
|
delete() {
|
||||||
return this.client.rest.methods.deleteInvite(this);
|
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;
|
module.exports = Invite;
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ const Endpoints = exports.Endpoints = {
|
|||||||
logout: `${API}/auth/logout`,
|
logout: `${API}/auth/logout`,
|
||||||
gateway: `${API}/gateway`,
|
gateway: `${API}/gateway`,
|
||||||
invite: (id) => `${API}/invite/${id}`,
|
invite: (id) => `${API}/invite/${id}`,
|
||||||
|
inviteLink: (id) => `https://discord.gg/${id}`,
|
||||||
CDN: 'https://cdn.discordapp.com',
|
CDN: 'https://cdn.discordapp.com',
|
||||||
|
|
||||||
// users
|
// users
|
||||||
|
|||||||
Reference in New Issue
Block a user