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

@ -125,21 +125,24 @@ class User extends Base {
// Code written by https://github.com/aiko-chan-ai // Code written by https://github.com/aiko-chan-ai
_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);
this.premiumSince = date.getTime(); this.premiumSince = date.getTime();
} }
if('premium_guild_since' in data) { if ('premium_guild_since' in data) {
const date = new Date(data.premium_guild_since); const date = new Date(data.premium_guild_since);
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]),
);
} }
/** /**
@ -147,13 +150,13 @@ class User extends Base {
* <br>Code written by https://github.com/aiko-chan-ai * <br>Code written by https://github.com/aiko-chan-ai
*/ */
async getProfile() { async getProfile() {
if(this.client.bot) throw new Error('INVALID_BOT_METHOD'); if (this.client.bot) throw new Error('INVALID_BOT_METHOD');
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;
} }
} }
@ -190,8 +193,8 @@ class User extends Base {
async setBlock() { async setBlock() {
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,
);
} }
/** /**
@ -257,7 +265,7 @@ class User extends Base {
* @readonly * @readonly
*/ */
get slashCommands() { get slashCommands() {
if(this.bot) { if (this.bot) {
return this.client.api.applications(this.id).commands.get(); return this.client.api.applications(this.id).commands.get();
} else return null; } else return null;
} }
@ -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: {