From 201e4376acb1eef59ee4ec5b97d7fcccd530f418 Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Thu, 11 Jan 2024 19:05:22 +0700 Subject: [PATCH] Update USER_REQUIRED_ACTION_UPDATE.js --- .../handlers/USER_REQUIRED_ACTION_UPDATE.js | 78 ++++++++++++++++++- 1 file changed, 75 insertions(+), 3 deletions(-) diff --git a/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js b/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js index ed94726..a7bc168 100644 --- a/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js +++ b/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js @@ -1,5 +1,77 @@ 'use strict'; -const Util = require('../../../util/Util'); - -module.exports = (client, { d: data }) => Util.clientRequiredAction(client, data.required_action); +module.exports = (client, { d: data }) => { + let msg; + switch (data.required_action) { + case null: { + msg = 'All required actions have been completed.'; + break; + } + case 'AGREEMENTS': { + msg = 'You need to accept the new Terms of Service and Privacy Policy.'; + // https://discord.com/api/v9/users/@me/agreements + client.api + .users('@me') + .agreements.patch({ + data: { + terms: true, + privacy: true, + }, + }) + .then(() => { + client.emit( + 'debug', + '[USER_REQUIRED_ACTION] Successfully accepted the new Terms of Service and Privacy Policy.', + ); + }) + .catch(e => { + client.emit( + 'debug', + `[USER_REQUIRED_ACTION] Failed to accept the new Terms of Service and Privacy Policy: ${e}`, + ); + }); + break; + } + case 'REQUIRE_CAPTCHA': { + msg = 'You need to complete a captcha.'; + break; + } + case 'REQUIRE_VERIFIED_EMAIL': { + msg = 'You need to verify your email.'; + break; + } + case 'REQUIRE_REVERIFIED_EMAIL': { + msg = 'You need to reverify your email.'; + break; + } + case 'REQUIRE_VERIFIED_PHONE': { + msg = 'You need to verify your phone number.'; + break; + } + case 'REQUIRE_REVERIFIED_PHONE': { + msg = 'You need to reverify your phone number.'; + break; + } + case 'REQUIRE_VERIFIED_EMAIL_OR_VERIFIED_PHONE': { + msg = 'You need to verify your email or verify your phone number.'; + break; + } + case 'REQUIRE_REVERIFIED_EMAIL_OR_VERIFIED_PHONE': { + msg = 'You need to reverify your email or verify your phone number.'; + break; + } + case 'REQUIRE_VERIFIED_EMAIL_OR_REVERIFIED_PHONE': { + msg = 'You need to verify your email or reverify your phone number.'; + break; + } + case 'REQUIRE_REVERIFIED_EMAIL_OR_REVERIFIED_PHONE': { + msg = 'You need to reverify your email or reverify your phone number.'; + break; + } + default: { + msg = `Unknown required action: ${data.required_action}`; + break; + } + } + client.emit('debug', `[USER_REQUIRED_ACTION] ${msg}`); +};