feat: ClientUserSettingManager

This commit is contained in:
Elysia
2024-01-22 19:12:59 +07:00
parent 59e8332987
commit 5401b51929
10 changed files with 465 additions and 56 deletions

View File

@@ -12,6 +12,7 @@ const { Error, TypeError, RangeError } = require('../errors');
const BaseGuildEmojiManager = require('../managers/BaseGuildEmojiManager');
const BillingManager = require('../managers/BillingManager');
const ChannelManager = require('../managers/ChannelManager');
const ClientUserSettingManager = require('../managers/ClientUserSettingManager');
const GuildManager = require('../managers/GuildManager');
const PresenceManager = require('../managers/PresenceManager');
const RelationshipManager = require('../managers/RelationshipManager');
@@ -188,6 +189,12 @@ class Client extends BaseClient {
*/
this.billing = new BillingManager(this);
/**
* All of the settings {@link Object}
* @type {ClientUserSettingManager}
*/
this.settings = new ClientUserSettingManager(this);
Object.defineProperty(this, 'token', { writable: true });
if (!this.token && 'DISCORD_TOKEN' in process.env) {
/**

View File

@@ -35,6 +35,9 @@ module.exports = (client, { d: data }, shard) => {
// Relationship
client.relationships._setup(data.relationships);
// ClientSetting
client.settings._patch(data.user_settings);
Promise.all(
largeGuilds.map(async (guild, index) => {
client.ws.broadcast({

View File

@@ -0,0 +1,5 @@
'use strict';
module.exports = (client, { d: data }) => {
client.settings._patch(data);
};

View File

@@ -73,6 +73,7 @@ const handlers = Object.fromEntries([
['CALL_CREATE', require('./CALL_CREATE')],
['CALL_UPDATE', require('./CALL_UPDATE')],
['CALL_DELETE', require('./CALL_DELETE')],
['USER_SETTINGS_UPDATE', require('./USER_SETTINGS_UPDATE')],
]);
module.exports = handlers;