Fix minor bug

- TypeError: this.client.rest.cdn.avatar is not a function
- ReferenceError: AllowedImageFormats is not defined
This commit is contained in:
March 7th 2022-03-23 18:36:58 +07:00
parent e8b87a1778
commit 6f6c986fd2
4 changed files with 373 additions and 355 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "discord.js-selfbot-v13", "name": "discord.js-selfbot-v13",
"version": "0.2.3", "version": "0.2.4",
"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",

View File

@ -127,7 +127,8 @@ class User extends Base {
_ProfilePatch(data) { _ProfilePatch(data) {
if (!data) return; if (!data) return;
if(data.connected_accounts.length > 0) this.connectedAccounds = data.connected_accounts; if (data.connected_accounts.length > 0)
this.connectedAccounds = data.connected_accounts;
if ('premium_since' in data) { if ('premium_since' in data) {
const date = new Date(data.premium_since); const date = new Date(data.premium_since);
@ -139,7 +140,9 @@ class User extends Base {
this.premiumGuildSince = date.getTime(); this.premiumGuildSince = date.getTime();
} }
this.mutualGuilds = new Collection(data.mutual_guilds.map((obj) => [obj.id, obj])); this.mutualGuilds = new Collection(
data.mutual_guilds.map((obj) => [obj.id, obj]),
);
} }
/** /**
@ -151,9 +154,9 @@ class User extends Base {
try { try {
const data = await this.client.api.users(this.id).profile.get(); const data = await this.client.api.users(this.id).profile.get();
this._ProfilePatch(data); this._ProfilePatch(data);
return this return this;
} catch (e) { } catch (e) {
throw e throw e;
} }
} }
@ -191,7 +194,7 @@ class User extends Base {
return this.client.api return this.client.api
.users('@me') .users('@me')
.relationships[this.id].put({ data: { type: 2 } }) .relationships[this.id].put({ data: { type: 2 } })
.then(_ => _) .then((_) => _);
} }
/** /**
@ -201,8 +204,7 @@ class User extends Base {
async unBlock() { async unBlock() {
return this.client.api return this.client.api
.users('@me') .users('@me')
.relationships[this.id].delete .relationships[this.id].delete.then((_) => _);
.then(_ => _)
} }
/** /**
@ -212,8 +214,7 @@ class User extends Base {
async unFriend() { async unFriend() {
return this.client.api return this.client.api
.users('@me') .users('@me')
.relationships[this.id].delete .relationships[this.id].delete.then((_) => _);
.then(_ => _)
} }
/** /**
@ -248,8 +249,15 @@ class User extends Base {
* @param {ImageURLOptions} [options={}] Options for the image URL * @param {ImageURLOptions} [options={}] Options for the image URL
* @returns {?string} * @returns {?string}
*/ */
avatarURL(options = {}) { avatarURL({ format, size, dynamic } = {}) {
return this.avatar && this.client.rest.cdn.avatar(this.id, this.avatar, options); if (!this.avatar) return null;
return this.client.rest.cdn.Avatar(
this.id,
this.avatar,
format,
size,
dynamic,
);
} }
/** /**
@ -298,7 +306,9 @@ class User extends Base {
* @returns {?string} * @returns {?string}
*/ */
bannerURL(options = {}) { bannerURL(options = {}) {
return this.banner && this.client.rest.cdn.banner(this.id, this.banner, options); return (
this.banner && this.client.rest.cdn.banner(this.id, this.banner, options)
);
} }
/** /**
@ -307,7 +317,9 @@ class User extends Base {
* @readonly * @readonly
*/ */
get tag() { get tag() {
return typeof this.username === 'string' ? `${this.username}#${this.discriminator}` : null; return typeof this.username === 'string'
? `${this.username}#${this.discriminator}`
: null;
} }
/** /**

View File

@ -200,6 +200,12 @@ exports.Events = {
GUILD_SCHEDULED_EVENT_USER_REMOVE: 'guildScheduledEventUserRemove', GUILD_SCHEDULED_EVENT_USER_REMOVE: 'guildScheduledEventUserRemove',
}; };
const AllowedImageFormats = ['webp', 'png', 'jpg', 'jpeg', 'gif'];
const AllowedImageSizes = [
16, 32, 56, 64, 96, 128, 256, 300, 512, 600, 1024, 2048, 4096,
];
function makeImageUrl(root, { format = 'webp', size } = {}) { function makeImageUrl(root, { format = 'webp', size } = {}) {
if (!['undefined', 'number'].includes(typeof size)) throw new TypeError('INVALID_TYPE', 'size', 'number'); if (!['undefined', 'number'].includes(typeof size)) throw new TypeError('INVALID_TYPE', 'size', 'number');
if (format && !AllowedImageFormats.includes(format)) throw new Error('IMAGE_FORMAT', format); if (format && !AllowedImageFormats.includes(format)) throw new Error('IMAGE_FORMAT', format);

View File

@ -101,7 +101,7 @@ class Options extends null {
$browser: 'Chrome', $browser: 'Chrome',
$device: 'ASUS ROG Phone 5', $device: 'ASUS ROG Phone 5',
}, },
version: 9, version: 10,
}, },
http: { http: {
headers: { headers: {