Throw Error

This commit is contained in:
March 7th 2022-03-19 19:06:13 +07:00
parent 89ed7a92d7
commit 38ee699313
2 changed files with 27 additions and 10 deletions

View File

@ -1,9 +1,12 @@
{ {
"name": "discord.js-selfbot-v13", "name": "discord.js-selfbot-v13",
"version": "0.0.1", "version": "0.0.2",
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]", "description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
"main": "./src/index.js", "main": "./src/index.js",
"types": "./typings/index.d.ts", "types": "./typings/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"files": [ "files": [
"src", "src",
"typings" "typings"
@ -41,7 +44,6 @@
"@sapphire/async-queue": "^1.3.0", "@sapphire/async-queue": "^1.3.0",
"@sapphire/snowflake": "^3.2.0", "@sapphire/snowflake": "^3.2.0",
"@types/ws": "^8.5.2", "@types/ws": "^8.5.2",
"crypto": "^1.0.1",
"discord-api-types": "^0.27.3", "discord-api-types": "^0.27.3",
"form-data": "^4.0.0", "form-data": "^4.0.0",
"lodash.snakecase": "^4.1.1", "lodash.snakecase": "^4.1.1",
@ -52,5 +54,10 @@
"engines": { "engines": {
"node": ">=16.9.0", "node": ">=16.9.0",
"npm": ">=7.0.0" "npm": ">=7.0.0"
},
"devDependencies": {
"eslint": "^8.11.0",
"prettier": "^2.6.0",
"tslint": "^6.1.3"
} }
} }

View File

@ -2,7 +2,7 @@
const CachedManager = require('./CachedManager'); const CachedManager = require('./CachedManager');
const { default: Collection } = require('@discordjs/collection'); const { default: Collection } = require('@discordjs/collection');
const { Error } = require('../errors/DJSError'); const { Error, TypeError } = require('../errors/DJSError');
/** /**
* Manages API methods for users and stores their cache. * Manages API methods for users and stores their cache.
* @extends {CachedManager} * @extends {CachedManager}
@ -152,6 +152,17 @@ class ClientUserSettingManager extends CachedManager {
*/ */
async setDisplayCompactMode(value) { async setDisplayCompactMode(value) {
if (this.client.bot) throw new Error('INVALID_BOT_METHOD'); if (this.client.bot) throw new Error('INVALID_BOT_METHOD');
if (
typeof value !== 'boolean' &&
typeof value !== 'null' &&
typeof value !== 'undefined'
)
throw new TypeError(
'INVALID_TYPE',
'value',
'boolean | null | undefined',
true,
);
if (!value) value = !this.compactMode; if (!value) value = !this.compactMode;
if (value !== this.compactMode) { if (value !== this.compactMode) {
await this.edit({ message_display_compact: value }); await this.edit({ message_display_compact: value });
@ -166,6 +177,7 @@ class ClientUserSettingManager extends CachedManager {
async setTheme(value) { async setTheme(value) {
if (this.client.bot) throw new Error('INVALID_BOT_METHOD'); if (this.client.bot) throw new Error('INVALID_BOT_METHOD');
const validValues = ['dark', 'light']; const validValues = ['dark', 'light'];
if (typeof value !== 'string' && typeof value !== 'null' && typeof value !== 'undefined') throw new TypeError('INVALID_TYPE', 'value', 'string | null | undefined', true);
if (!validValues.includes(value)) { if (!validValues.includes(value)) {
value == validValues[0] value == validValues[0]
? (value = validValues[1]) ? (value = validValues[1])
@ -177,7 +189,7 @@ class ClientUserSettingManager extends CachedManager {
return this.theme; return this.theme;
} }
/** /**
* Locale Setting, must be one of: * * Locale Setting, must be one of:
* * `DANISH` * * `DANISH`
* * `GERMAN` * * `GERMAN`
* * `ENGLISH_UK` * * `ENGLISH_UK`
@ -208,21 +220,19 @@ class ClientUserSettingManager extends CachedManager {
* * `JAPANESE` * * `JAPANESE`
* * `TAIWAN_CHINESE` * * `TAIWAN_CHINESE`
* * `KOREAN` * * `KOREAN`
* @typedef {string} LocaleStrings * @param {string} value
*/
/**
*
* @param {LocaleStrings} value
* @returns {locale} * @returns {locale}
*/ */
async setLocale(value) { async setLocale(value) {
if (this.client.bot) throw new Error('INVALID_BOT_METHOD'); if (this.client.bot) throw new Error('INVALID_BOT_METHOD');
if (typeof value !== 'string') throw new TypeError('INVALID_TYPE', 'value', 'string', true);
if (!localeObject[value]) throw new Error('INVALID_LOCALE'); if (!localeObject[value]) throw new Error('INVALID_LOCALE');
if (localeObject[value] !== this.locale) { if (localeObject[value] !== this.locale) {
await this.edit({ locale: localeObject[value] }); await this.edit({ locale: localeObject[value] });
} }
return this.locale; return this.locale;
} }
// TODO: Guild positions & folders
} }
module.exports = ClientUserSettingManager; module.exports = ClientUserSettingManager;