access profiles with username instead of id
This commit is contained in:
@ -5,21 +5,21 @@ class Profile
|
||||
/**
|
||||
* @param {Client} client
|
||||
*/
|
||||
constructor (client, id, username = undefined, avatar_url = undefined)
|
||||
constructor (client, username, id = undefined, avatar_url = undefined)
|
||||
{
|
||||
/**
|
||||
* @type {Client} client
|
||||
*/
|
||||
this.client = client;
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.id = id;
|
||||
this.avatar_url = avatar_url;
|
||||
this.isBlocked = false;
|
||||
}
|
||||
|
||||
async init()
|
||||
{
|
||||
let response = await this.client._get(`/api/profiles/${this.id}`);
|
||||
let response = await this.client._get(`/api/profiles/${this.username}`);
|
||||
|
||||
if (response.status !== 200)
|
||||
return response.status;
|
||||
|
@ -20,14 +20,14 @@ class Profiles
|
||||
|
||||
let profiles = []
|
||||
response_data.forEach((profile) => {
|
||||
profiles.push(new Profile(this.client, profile.user_id, profile.username, profile.avatar_url))
|
||||
profiles.push(new Profile(this.client, profile.username, profile.user_id, profile.avatar_url))
|
||||
});
|
||||
return profiles;
|
||||
}
|
||||
|
||||
async getProfile(user_id)
|
||||
async getProfile(username)
|
||||
{
|
||||
let profile = new Profile(this.client, user_id);
|
||||
let profile = new Profile(this.client, username);
|
||||
if (await profile.init())
|
||||
return null;
|
||||
return profile;
|
||||
|
Reference in New Issue
Block a user