From d1382823fe82c83ad1ec5de98ac5a96b2d51f460 Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Sun, 11 Sep 2022 09:18:25 +0700 Subject: [PATCH] feat(RelationshipManager): Add `x-context-properties` headers --- src/managers/RelationshipManager.js | 18 +++++++++++++++--- src/structures/ApplicationCommand.js | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/managers/RelationshipManager.js b/src/managers/RelationshipManager.js index cb4ae28..adcb604 100644 --- a/src/managers/RelationshipManager.js +++ b/src/managers/RelationshipManager.js @@ -1,5 +1,6 @@ 'use strict'; +const Buffer = require('node:buffer').Buffer; const { Collection } = require('@discordjs/collection'); const { GuildMember } = require('../structures/GuildMember'); const { Message } = require('../structures/Message'); @@ -125,8 +126,6 @@ class RelationshipManager { return this.cache.get(id); } - // Some option .-. - /** * Deletes a friend relationship with a client user. * @param {UserResolvable} user Target @@ -163,6 +162,9 @@ class RelationshipManager { username, discriminator: parseInt(discriminator), }, + headers: { + 'X-Context-Properties': Buffer.from(JSON.stringify({ location: 'Add Friend' }), 'utf8').toString('base64'), + }, }); return true; } @@ -179,7 +181,11 @@ class RelationshipManager { } async __cancel(id) { - await this.client.api.users['@me'].relationships[id].delete(); + await this.client.api.users['@me'].relationships[id].delete({ + headers: { + 'X-Context-Properties': Buffer.from(JSON.stringify({ location: 'Friends' }), 'utf8').toString('base64'), + }, + }); return true; } @@ -198,6 +204,9 @@ class RelationshipManager { data: { type: RelationshipTypes.FRIEND, }, + headers: { + 'X-Context-Properties': Buffer.from(JSON.stringify({ location: 'Friends' }), 'utf8').toString('base64'), + }, }); return true; } @@ -215,6 +224,9 @@ class RelationshipManager { data: { type: RelationshipTypes.BLOCKED, }, + headers: { + 'X-Context-Properties': Buffer.from(JSON.stringify({ location: 'ContextMenu' }), 'utf8').toString('base64'), + }, }); return true; } diff --git a/src/structures/ApplicationCommand.js b/src/structures/ApplicationCommand.js index cb2c8c4..97ab8f5 100644 --- a/src/structures/ApplicationCommand.js +++ b/src/structures/ApplicationCommand.js @@ -51,6 +51,7 @@ class ApplicationCommand extends Base { /** * The guild this command is part of * @type {?Guild} + * @readonly */ get guild() { return this.client.guilds.resolve(this.guildId);