export interface User {
	username: string;
	discriminator: string;
	id: string;
	public_flags: number;
	avatar: string | null;
	accent_color: number;
	banner?: string;
	bio: string;
	bot: boolean;
	premium_since: string;
	premium_type: number;
	theme_colors: [number, number] | null;
	pronouns?: string;
	badge_ids: string[];
	uid?: string;
};

export type MainUser = User & {
	flags: number;
	mfa_enabled?: boolean;
	email?: string;
	phone?: string;
	verified: boolean;
	nsfw_allowed: boolean;
	premium: boolean;
	purchased_flags: number;
	premium_usage_flags: number;
	disabled: boolean;
};

export interface PrivateChannel {
	id: string;
	flags: number;
	name?: string | null;
	icon?: string;
	last_message_id: string;
	type: number;
	recipients: User[];
	is_spam: boolean;
	owner_id?: string;
};

export interface File {
	id: string;
	filename: string;
	content_type: string;
	width?: number;
	height?: number;
	proxy_url?: string;
	url: string;
	size: number;
};

export interface Message {
	id: string;
	channel_id: string;
	guild_id: string;
	author: User;
	//member?: memberjson;
	content: string;
	timestamp: string;
	edited_timestamp: string | null;
	tts: boolean;
	mention_everyone: boolean;
	mentions: [];
	mention_roles?: [];
	attachments: File[];
	//embeds: embedjson[];
	//components?: component[] | null;
	/*reactions?: {
		count: number;
		emoji: emojijson;
		me: boolean;
	}[];
	interaction?: {
		id: string;
		type: 2 | 3;
		user: userjson;
	};
	interaction_metadata?: {
		authorizing_integration_owners: {
			//User ids
			[key: string]: string;
		};
		id: string;
		type: 2 | 3;
		user: userjson;
	};*/
	nonce: string;
	pinned: boolean;
	type: number;
	//webhook?: webhookInfo;
	//sticker_items: stickerJson[];
	message_reference?: string;
};

export function getChannelName(channel?: PrivateChannel) {
  if (!channel) return "Unknown";

  const { name, recipients } = channel;
  if (name && name.trim() !== "") return name;

  const firstRecipient = recipients?.[0]?.username;
  if (firstRecipient && firstRecipient.trim() !== "") return firstRecipient;

  return "Unknown";
}