friend invite
This commit is contained in:
parent
46ba5d3058
commit
2b2c6e184c
File diff suppressed because one or more lines are too long
@ -1,11 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
|
const Invite = require('./Invite');
|
||||||
const User = require('./User');
|
const User = require('./User');
|
||||||
const { Util } = require('..');
|
const { Util } = require('..');
|
||||||
const { HypeSquadOptions, Opcodes, NitroState } = require('../util/Constants');
|
const { HypeSquadOptions, Opcodes, NitroState } = require('../util/Constants');
|
||||||
const DataResolver = require('../util/DataResolver');
|
const DataResolver = require('../util/DataResolver');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the logged in client's Discord user.
|
* Represents the logged in client's Discord user.
|
||||||
* @extends {User}
|
* @extends {User}
|
||||||
@ -410,6 +410,30 @@ class ClientUser extends User {
|
|||||||
setAFK(afk = true, shardId) {
|
setAFK(afk = true, shardId) {
|
||||||
return this.setPresence({ afk, shardId });
|
return this.setPresence({ afk, shardId });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an invite [Friend Invites]
|
||||||
|
* @param {CreateInviteOptions} [options={}] The options for creating the invite [maxAge and maxUses are available]
|
||||||
|
* @returns {Promise<Invite>}
|
||||||
|
* @see https://github.com/13-05/hidden-disc-docs#js-snippet-for-creating-friend-invites
|
||||||
|
* @example
|
||||||
|
* // Create an invite to a selected channel
|
||||||
|
* client.user.getInvite({ maxAge: 0, maxUses: 0 });
|
||||||
|
* .then(console.log)
|
||||||
|
* .catch(console.error);
|
||||||
|
*/
|
||||||
|
async getInvite({ maxAge = 86400, maxUses = 0 } = {}) {
|
||||||
|
const data = await this.client.api.users['@me'].invites.post({
|
||||||
|
data: {
|
||||||
|
validate: null,
|
||||||
|
max_age: maxAge,
|
||||||
|
max_uses: maxUses,
|
||||||
|
target_type: 2,
|
||||||
|
temporary: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return new Invite(this.client, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ClientUser;
|
module.exports = ClientUser;
|
||||||
|
@ -178,7 +178,7 @@ class Invite extends Base {
|
|||||||
this.channel = this.client.channels.cache.get(data.channel_id);
|
this.channel = this.client.channels.cache.get(data.channel_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('channel' in data) {
|
if ('channel' in data && data.channel) {
|
||||||
/**
|
/**
|
||||||
* The channel this invite is for
|
* The channel this invite is for
|
||||||
* @type {Channel}
|
* @type {Channel}
|
||||||
@ -324,6 +324,7 @@ class Invite extends Base {
|
|||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
async acceptInvite(autoVerify = true) {
|
async acceptInvite(autoVerify = true) {
|
||||||
|
if (!this.guild) throw new Error('INVITE_NO_GUILD');
|
||||||
await this.client.api.invites(this.code).post({});
|
await this.client.api.invites(this.code).post({});
|
||||||
if (autoVerify) {
|
if (autoVerify) {
|
||||||
const getForm = await this.client.api
|
const getForm = await this.client.api
|
||||||
|
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
@ -657,6 +657,7 @@ export class ClientUser extends User {
|
|||||||
public deleteAccount(password: string): Promise<this>;
|
public deleteAccount(password: string): Promise<this>;
|
||||||
public setDeaf(status: boolean): Promise<boolean>;
|
public setDeaf(status: boolean): Promise<boolean>;
|
||||||
public setMute(status: boolean): Promise<boolean>;
|
public setMute(status: boolean): Promise<boolean>;
|
||||||
|
public getInvite(options?: CreateInviteOptions): Promise<Invite>;
|
||||||
/**
|
/**
|
||||||
* Nitro Status
|
* Nitro Status
|
||||||
* `0`: None
|
* `0`: None
|
||||||
|
Loading…
Reference in New Issue
Block a user