mirror of
https://github.com/danbulant/discord.js
synced 2026-07-08 12:40:50 +00:00
Add Invite.url and toString
This commit is contained in:
parent
8bcb670920
commit
0bd00b12b7
3 changed files with 23 additions and 1 deletions
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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue