adds support for role settings and various fixes

This commit is contained in:
MathMan05 2024-06-30 22:05:14 -05:00
parent 96b2dbb21c
commit 8fe0c9f46b
20 changed files with 1199 additions and 183 deletions

View file

@ -13,6 +13,18 @@ class User {
discriminator;
pronouns;
bot;
static contextmenu = new Contextmenu("User Menu");
static setUpContextMenu() {
this.contextmenu.addbutton("Copy user id", function () {
navigator.clipboard.writeText(this.id);
});
this.contextmenu.addbutton("Message user", function () {
fetch(this.info.api.toString() + "/v9/users/@me/channels", { method: "POST",
body: JSON.stringify({ "recipients": [this.id] }),
headers: this.headers
});
});
}
static checkuser(userjson, owner) {
if (User.userids[userjson.id]) {
return User.userids[userjson.id];
@ -60,6 +72,21 @@ class User {
this.changepfp(json.avatar);
}
}
bind(html, guild = null) {
if (guild && guild.id !== "@me") {
Member.resolve(this, guild).then(_ => {
_.bind(html);
}).catch(_ => {
console.log(_);
});
}
this.profileclick(html);
User.contextmenu.bind(html, this);
}
static async resolve(id, localuser) {
const json = await fetch(localuser.info.api.toString() + "/v9/users/" + id + "/profile", { headers: localuser.headers }).then(_ => _.json());
return new User(json, localuser);
}
changepfp(update) {
this.avatar = update;
this.hypotheticalpfp = false;
@ -137,4 +164,5 @@ class User {
};
}
}
User.setUpContextMenu();
export { User };