mirror of
https://github.com/MathMan05/Fermi.git
synced 2026-10-23 00:01:22 +00:00
user notes
This commit is contained in:
1 parent
56e9ef7732
commit
eeff93db28
5 files changed
+67
-1
No files matched your search
@@ -939,6 +939,27 @@ type messageCreateJson = {
|
||||
s: number;
|
||||
t: "MESSAGE_CREATE";
|
||||
};
|
||||
type userNote = {
|
||||
op: 0;
|
||||
t: "USER_NOTE_UPDATE";
|
||||
d: {
|
||||
note: string;
|
||||
id: string;
|
||||
};
|
||||
s: number;
|
||||
};
|
||||
export type pollUpdateJson = {
|
||||
op: 0;
|
||||
d: {
|
||||
user_id: string;
|
||||
channel_id: string;
|
||||
message_id: string;
|
||||
guild_id?: string;
|
||||
answer_id: number;
|
||||
};
|
||||
s: number;
|
||||
t: "MESSAGE_POLL_VOTE_ADD" | "MESSAGE_POLL_VOTE_REMOVE";
|
||||
};
|
||||
export interface relationJson {
|
||||
id: string;
|
||||
type: 0 | 1 | 2 | 3 | 4;
|
||||
@@ -1030,6 +1051,7 @@ type wsjson =
|
||||
heartbeat_interval: number;
|
||||
};
|
||||
}
|
||||
| userNote
|
||||
| {
|
||||
op: 0;
|
||||
t: "MESSAGE_REACTION_ADD";
|
||||
|
||||
@@ -769,6 +769,11 @@ class Localuser {
|
||||
this.messageCreate(temp);
|
||||
}
|
||||
break;
|
||||
case "USER_NOTE_UPDATE": {
|
||||
const u = this.userMap.get(temp.d.id);
|
||||
if (u) u.note = temp.d.note;
|
||||
break;
|
||||
}
|
||||
case "USER_CONNECTIONS_UPDATE": {
|
||||
this.conectionChange();
|
||||
break;
|
||||
|
||||
@@ -422,6 +422,9 @@ body {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
.userNote {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
#player {
|
||||
flex-grow: 0;
|
||||
|
||||
|
||||
@@ -1173,6 +1173,33 @@ class User extends SnowFlake {
|
||||
}
|
||||
}
|
||||
}
|
||||
note?: string;
|
||||
async saveNotes(note: string) {
|
||||
this.note = note;
|
||||
await fetch(`${this.info.api}/users/@me/notes/${this.id}`, {
|
||||
method: "PUT",
|
||||
headers: this.headers,
|
||||
body: JSON.stringify({note}),
|
||||
});
|
||||
}
|
||||
async getNotes() {
|
||||
try {
|
||||
if (this.note === undefined) {
|
||||
this.note =
|
||||
(
|
||||
await (
|
||||
await fetch(`${this.info.api}/users/@me/notes/${this.id}`, {
|
||||
method: "GET",
|
||||
headers: this.headers,
|
||||
})
|
||||
).json()
|
||||
).note || "";
|
||||
}
|
||||
} catch {
|
||||
this.note = "";
|
||||
}
|
||||
return this.note as string;
|
||||
}
|
||||
async fullProfile(guild: Guild | null | Member = null) {
|
||||
console.log(guild);
|
||||
const membres = (async () => {
|
||||
@@ -1380,6 +1407,14 @@ class User extends SnowFlake {
|
||||
document.body.append(background);
|
||||
background.append(div);
|
||||
console.log(background);
|
||||
const notes = buttons.add(I18n.profile.notes());
|
||||
const textArea = document.createElement("textarea");
|
||||
textArea.classList.add("userNote");
|
||||
notes.addHTMLArea(textArea);
|
||||
this.getNotes().then((_) => (textArea.textContent = _));
|
||||
textArea.onblur = () => {
|
||||
this.saveNotes(textArea.value);
|
||||
};
|
||||
(async () => {
|
||||
const high = await this.highInfo();
|
||||
const mut = buttons.add(I18n.profile.mut());
|
||||
|
||||
@@ -773,7 +773,8 @@
|
||||
"mut": "Mutual guilds",
|
||||
"mutFriends": "Mutual friends",
|
||||
"permInfo": "Permissions",
|
||||
"userInfo": "User info"
|
||||
"userInfo": "User info",
|
||||
"notes":"User notes"
|
||||
},
|
||||
"profileColor": "Profile color",
|
||||
"pronouns": "Pronouns:",
|
||||
|
||||
Reference in new issue
Block a user