feat: add a fuck ton of get functions
This commit is contained in:
parent
58fe9a2eac
commit
69feff6cf8
8 changed files with 81 additions and 0 deletions
21
utils/getFriendsSince.ts
Normal file
21
utils/getFriendsSince.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import type { GuildMemberResponse, UserResponse } from "~/types/interfaces";
|
||||
|
||||
const { fetchFriends } = useApi();
|
||||
|
||||
export default async (profile: UserResponse | GuildMemberResponse): Promise<Date | null> => {
|
||||
let user_uuid: string;
|
||||
|
||||
if ("username" in profile) {
|
||||
user_uuid = profile.uuid
|
||||
} else {
|
||||
user_uuid = profile.user_uuid
|
||||
}
|
||||
|
||||
const friends = await fetchFriends()
|
||||
const friend = friends.find(friend => friend.uuid === user_uuid);
|
||||
if (friend?.friends_since) {
|
||||
return new Date(friend.friends_since);
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue