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",
"version": "0.2.3",
"version": "0.2.4",
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
"main": "./src/index.js",
"types": "./typings/index.d.ts",

View File

@ -125,21 +125,24 @@ class User extends Base {
// Code written by https://github.com/aiko-chan-ai
_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);
this.premiumSince = date.getTime();
}
if('premium_guild_since' in data) {
if ('premium_guild_since' in data) {
const date = new Date(data.premium_guild_since);
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
*/
async getProfile() {
if(this.client.bot) throw new Error('INVALID_BOT_METHOD');
if (this.client.bot) throw new Error('INVALID_BOT_METHOD');
try {
const data = await this.client.api.users(this.id).profile.get();
this._ProfilePatch(data);
return this
return this;
} catch (e) {
throw e
throw e;
}
}
@ -190,8 +193,8 @@ class User extends Base {
async setBlock() {
return this.client.api
.users('@me')
.relationships[this.id].put({data:{type: 2}})
.then(_ => _)
.relationships[this.id].put({ data: { type: 2 } })
.then((_) => _);
}
/**
@ -201,8 +204,7 @@ class User extends Base {
async unBlock() {
return this.client.api
.users('@me')
.relationships[this.id].delete
.then(_ => _)
.relationships[this.id].delete.then((_) => _);
}
/**
@ -212,8 +214,7 @@ class User extends Base {
async unFriend() {
return this.client.api
.users('@me')
.relationships[this.id].delete
.then(_ => _)
.relationships[this.id].delete.then((_) => _);
}
/**
@ -248,8 +249,15 @@ class User extends Base {
* @param {ImageURLOptions} [options={}] Options for the image URL
* @returns {?string}
*/
avatarURL(options = {}) {
return this.avatar && this.client.rest.cdn.avatar(this.id, this.avatar, options);
avatarURL({ format, size, dynamic } = {}) {
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
*/
get slashCommands() {
if(this.bot) {
if (this.bot) {
return this.client.api.applications(this.id).commands.get();
} else return null;
}
@ -298,7 +306,9 @@ class User extends Base {
* @returns {?string}
*/
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
*/
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',
};
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 } = {}) {
if (!['undefined', 'number'].includes(typeof size)) throw new TypeError('INVALID_TYPE', 'size', 'number');
if (format && !AllowedImageFormats.includes(format)) throw new Error('IMAGE_FORMAT', format);

View File

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