Sort members list #45
5 changed files with 5 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
|||
import type { GuildMemberResponse, UserResponse } from "~/types/interfaces";
|
||||
|
||||
export function getDisplayName(user: UserResponse, member?: GuildMemberResponse): string {
|
||||
export default (user: UserResponse, member?: GuildMemberResponse): string => {
|
||||
if (member?.nickname) return member.nickname
|
||||
if (user.display_name) return user.display_name
|
||||
return user.username
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export async function hashPassword(password: string) {
|
||||
export default async (password: string) => {
|
||||
const encodedPass = new TextEncoder().encode(password);
|
||||
const hashBuffer = await crypto.subtle.digest("SHA-384", encodedPass);
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { GuildMemberResponse } from "~/types/interfaces";
|
||||
|
||||
export default function sortMembers(members: GuildMemberResponse[]): GuildMemberResponse[] {
|
||||
export default (members: GuildMemberResponse[]): GuildMemberResponse[] => {
|
||||
return members.sort((a, b) => {
|
||||
return getDisplayName(a.user, a).localeCompare(getDisplayName(b.user, b))
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { UserResponse } from "~/types/interfaces";
|
||||
|
||||
export default function sortUsers(users: UserResponse[]): UserResponse[] {
|
||||
export default (users: UserResponse[]): UserResponse[] => {
|
||||
return users.sort((a, b) => {
|
||||
return getDisplayName(a).localeCompare(getDisplayName(b))
|
||||
})
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export function validateUsername(username: string) {
|
||||
export default (username: string) => {
|
||||
return /^[\w.-]+$/.test(username);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue