From 0ca1bf5397347c99f2d355cefd0d494adc5dec64 Mon Sep 17 00:00:00 2001 From: Cinnamon <71698422+aiko-chan-ai@users.noreply.github.com> Date: Sat, 25 Jun 2022 10:09:49 +0700 Subject: [PATCH] fix(UserManager): CreateDM function --- src/managers/UserManager.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/managers/UserManager.js b/src/managers/UserManager.js index 401979e..1a8ae31 100644 --- a/src/managers/UserManager.js +++ b/src/managers/UserManager.js @@ -5,6 +5,7 @@ const { GuildMember } = require('../structures/GuildMember'); const { Message } = require('../structures/Message'); const ThreadMember = require('../structures/ThreadMember'); const User = require('../structures/User'); +const { Opcodes } = require('../util/Constants'); /** * Manages API methods for users and stores their cache. @@ -57,10 +58,20 @@ class UserManager extends CachedManager { const data = await this.client.api.users(this.client.user.id).channels.post({ data: { - recipient_id: id, + recipients: [id], + }, + headers: { + 'X-Context-Properties': 'e30=', // {} }, }); - return this.client.channels._add(data, null, { cache }); + const dm_channel = await this.client.channels._add(data, null, { cache }); + await this.client.ws.broadcast({ + op: Opcodes.DM_UPDATE, + d: { + channel_id: dm_channel.id, + }, + }); + return dm_channel; } /**