"use client"; import { useEffect, useState } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs"; import { User, Bot, Brain, Settings, CloudSun, Smartphone, Heart, Cat, Dices, Thermometer, BarChart3, LogOut, Edit3, Save, X, Network, Cpu, Languages, Bug, Lightbulb, ExternalLink, Quote, Info, Shuffle, Rainbow, Database, Hash, Download, Archive } from "lucide-react"; import { RiTelegram2Line } from "react-icons/ri"; import { motion } from "framer-motion"; import { ModelPicker } from "@/components/account/model-picker"; import { useAuth } from "@/contexts/auth-context"; import { FaLastfm } from "react-icons/fa"; import { TiInfinity } from "react-icons/ti"; interface CommandCard { id: string; icon: React.ComponentType>; title: string; description: string; commands: string[]; category: "ai" | "entertainment" | "utility" | "media" | "admin" | "animals"; gradient: string; enabled: boolean; } const allCommands: CommandCard[] = [ { id: "ai-ask-think", icon: Brain, title: "AI Chats", description: "Chat with AI models and use deep thinking", commands: ["/ask", "/think"], category: "ai", gradient: "from-purple-500 to-pink-500", enabled: true }, { id: "ai-custom", icon: Bot, title: "Custom AI Model", description: "Use your personally configured AI model", commands: ["/ai"], category: "ai", gradient: "from-indigo-500 to-purple-500", enabled: true }, { id: "ai-stats", icon: BarChart3, title: "AI Statistics", description: "View your AI usage statistics", commands: ["/aistats"], category: "ai", gradient: "from-purple-600 to-indigo-600", enabled: true }, { id: "games-dice", icon: Dices, title: "Interactive Emojis", description: "Roll dice, play slots, and other interactive emojis", commands: ["/dice", "/slot", "/ball", "/dart", "/bowling"], category: "entertainment", gradient: "from-green-500 to-teal-500", enabled: true }, { id: "fun-random", icon: Shuffle, title: "Fun Commands", description: "Random numbers and fun responses", commands: ["/random", "/furry", "/gay"], category: "entertainment", gradient: "from-pink-500 to-rose-500", enabled: true }, { id: "infinite-dice", icon: TiInfinity, title: "Infinite Dice", description: "Sends an infinite dice sticker", commands: ["/idice"], category: "entertainment", gradient: "from-yellow-500 to-orange-500", enabled: true }, { id: "animals-basic", icon: Cat, title: "Animal Pictures", description: "Get random cute animal pictures", commands: ["/cat", "/dog", "/duck", "/fox"], category: "animals", gradient: "from-orange-500 to-red-500", enabled: true }, { id: "soggy-cat", icon: Heart, title: "Soggy Cat", description: "Wet cats!", commands: ["/soggy", "/soggycat"], category: "animals", gradient: "from-blue-500 to-purple-500", enabled: true }, { id: "weather", icon: CloudSun, title: "Weather", description: "Get current weather for any location", commands: ["/weather", "/clima"], category: "utility", gradient: "from-blue-500 to-cyan-500", enabled: true }, { id: "device-specs", icon: Smartphone, title: "Device Specifications", description: "Look up phone specifications via GSMArena", commands: ["/device", "/d"], category: "utility", gradient: "from-slate-500 to-gray-500", enabled: true }, { id: "http-status", icon: Network, title: "HTTP Status Codes", description: "Look up HTTP status codes and meanings", commands: ["/http", "/httpcat"], category: "utility", gradient: "from-emerald-500 to-green-500", enabled: true }, { id: "codename-lookup", icon: Hash, title: "Codename Lookup", description: "Look up codenames and meanings", commands: ["/codename", "/whatis"], category: "utility", gradient: "from-teal-500 to-cyan-500", enabled: true }, { id: "info-commands", icon: Info, title: "Information", description: "Get chat and user information", commands: ["/chatinfo", "/userinfo"], category: "utility", gradient: "from-indigo-500 to-blue-500", enabled: true }, { id: "quotes", icon: Quote, title: "Random Quotes", description: "Get random quotes", commands: ["/quote"], category: "utility", gradient: "from-amber-500 to-yellow-500", enabled: true }, { id: "youtube-download", icon: Download, title: "Video Downloads", description: "Download videos from YouTube and 1000+ platforms", commands: ["/yt", "/ytdl", "/video", "/dl"], category: "media", gradient: "from-red-500 to-pink-500", enabled: true }, { id: "lastfm", icon: FaLastfm, title: "Last.fm Integration", description: "Connect your music listening history", commands: ["/last", "/lfm", "/setuser"], category: "media", gradient: "from-violet-500 to-purple-500", enabled: true }, { id: "mlp-content", icon: Database, title: "MLP Database", description: "My Little Pony content and information", commands: ["/mlp", "/mlpchar", "/mlpep", "/mlpcomic"], category: "media", gradient: "from-fuchsia-500 to-pink-500", enabled: true }, { id: "modarchive", icon: Archive, title: "Mod Archive", description: "Access classic tracker music files", commands: ["/modarchive", "/tma"], category: "media", gradient: "from-cyan-500 to-blue-500", enabled: true }, { id: "random-pony", icon: Rainbow, title: "Random Pony Art", description: "Get random My Little Pony artwork", commands: ["/rpony", "/randompony", "/mlpart"], category: "media", gradient: "from-pink-500 to-purple-500", enabled: true }, ]; const categoryColors = { ai: "bg-purple-500/10 text-purple-600 border-purple-200 dark:border-purple-800", entertainment: "bg-green-500/10 text-green-600 border-green-200 dark:border-green-800", utility: "bg-blue-500/10 text-blue-600 border-blue-200 dark:border-blue-800", media: "bg-red-500/10 text-red-600 border-red-200 dark:border-red-800", admin: "bg-orange-500/10 text-orange-600 border-orange-200 dark:border-orange-800", animals: "bg-emerald-500/10 text-emerald-600 border-emerald-200 dark:border-emerald-800" }; const languageOptions = [ { code: 'en', name: 'English', flag: '🇺🇸' }, { code: 'pt', name: 'Português', flag: '🇧🇷' }, ]; export default function AccountPage() { const [editingTemp, setEditingTemp] = useState(false); const [tempValue, setTempValue] = useState(""); const [selectedCategory, setSelectedCategory] = useState(null); const [reportTab, setReportTab] = useState("bug"); const [commands, setCommands] = useState(allCommands); const { user, loading, logout, refreshUser } = useAuth(); useEffect(() => { if (user) { setTempValue(user.aiTemperature.toString()); setCommands(allCommands.map(cmd => ({ ...cmd, enabled: !user.disabledCommands.includes(cmd.id) }))); } }, [user]); const updateSetting = async (setting: string, value: boolean | number | string) => { try { const response = await fetch('/api/user/settings', { method: 'PATCH', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ [setting]: value }), credentials: 'include' }); if (response.ok) { await refreshUser(); } } catch (error) { console.error('Error updating setting:', error); } }; const saveTemperature = () => { const temp = parseFloat(tempValue); if (temp >= 0.1 && temp <= 2.0) { updateSetting('aiTemperature', temp); setEditingTemp(false); } }; const toggleCommand = async (commandId: string) => { if (!user) return; const commandToToggle = commands.find(cmd => cmd.id === commandId); if (!commandToToggle) return; const newEnabledState = !commandToToggle.enabled; setCommands(prev => prev.map(cmd => cmd.id === commandId ? { ...cmd, enabled: newEnabledState } : cmd )); try { let newDisabledCommands: string[]; if (newEnabledState) { newDisabledCommands = user.disabledCommands.filter(id => id !== commandId); } else { newDisabledCommands = [...user.disabledCommands, commandId]; } const response = await fetch('/api/user/settings', { method: 'PATCH', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ disabledCommands: newDisabledCommands }), credentials: 'include' }); if (response.ok) { await refreshUser(); } else { setCommands(prev => prev.map(cmd => cmd.id === commandId ? { ...cmd, enabled: !newEnabledState } : cmd )); console.error('Failed to update command state'); } } catch (error) { setCommands(prev => prev.map(cmd => cmd.id === commandId ? { ...cmd, enabled: !newEnabledState } : cmd )); console.error('Error updating command state:', error); } }; const filteredCommands = selectedCategory ? commands.filter(cmd => cmd.category === selectedCategory) : commands; if (loading) { return (
); } if (!user) { return (

Authentication Required

); } return (

Welcome back, {user.firstName}!

@{user.username}

AI Usage

{user.aiRequests}

Total AI Requests

{user.aiCharacters.toLocaleString()}

Characters Generated

AI Settings

AI Enabled
Show Thinking

Temperature

{editingTemp ? ( <> setTempValue(e.target.value)} className="h-8 w-20" /> ) : ( <> {user.aiTemperature} )}

Controls randomness in AI responses. Lower values (0.1-0.5) = more focused, higher values (0.7-2.0) = more creative.

Language Options

{languageOptions.map((lang) => ( ))}

Choose your preferred language for bot responses and interface text.

My Model

updateSetting('customAiModel', newModel)} className="w-full" />

Your selected AI model for custom /ai commands. Different models have varying capabilities, speeds, and response styles.

Report An Issue

Bug Report Feature Request

Found a bug or issue? Report it to help us improve Kowalski.

Have an idea for a new feature? Let us know what you'd like to see!

Command Management

{Object.entries(categoryColors).map(([category, colorClass]) => ( ))}
{filteredCommands.map((command) => (
toggleCommand(command.id)} >

{command.title}

{command.description}

{command.commands.slice(0, 2).map((cmd, idx) => ( {cmd} ))} {command.commands.length > 2 && ( +{command.commands.length - 2} )}
{command.category === "ai" ? "AI" : command.category}
))}
Ready to start using Kowalski?
); }