feat(bots): bot framework polish + store

- /ws/bot endpoint: bot token auth via query param, SHA-256 lookup
- Bot WS actions: SEND_MESSAGE + DELETE_MESSAGE handled in gateway
- Bot messages: bot_id on messages table, bot badge in chat (green + BOT tag)
- Bot store: /bots lists all bots with server count + add-to-server
- Bot manager moved to /bots/manage
- Fix: command routes were double-nested under /bots/{botID}/commands
- Fix: fetchServerCommands route corrected to /bots/servers/...
This commit is contained in:
2026-07-15 12:45:44 -04:00
parent 2674c254a1
commit 7c70082f37
13 changed files with 557 additions and 22 deletions
+27 -1
View File
@@ -18,12 +18,24 @@ export interface SlashCommand {
description: string;
}
export interface StoreBot {
id: string;
name: string;
avatar: string | null;
description: string;
server_count: number;
owner_id: string;
created_at: string;
}
interface BotState {
bots: Bot[];
storeBots: StoreBot[];
loading: boolean;
error: string | null;
fetchBots: () => Promise<void>;
fetchStoreBots: () => Promise<void>;
createBot: (name: string, description: string) => Promise<Bot & { token: string }>;
updateBot: (id: string, data: { name?: string; description?: string; avatar?: string }) => Promise<Bot>;
deleteBot: (id: string) => Promise<void>;
@@ -39,6 +51,7 @@ interface BotState {
export const useBotStore = create<BotState>((set) => ({
bots: [],
storeBots: [],
loading: false,
error: null,
@@ -55,6 +68,19 @@ export const useBotStore = create<BotState>((set) => ({
}
},
fetchStoreBots: async () => {
set({ loading: true, error: null });
try {
const storeBots = await api.get<StoreBot[]>('/bots/store');
set({ storeBots, loading: false });
} catch (error) {
set({
loading: false,
error: error instanceof Error ? error.message : 'Failed to fetch bot store',
});
}
},
createBot: async (name, description) => {
set({ loading: true, error: null });
try {
@@ -189,7 +215,7 @@ export const useBotStore = create<BotState>((set) => ({
fetchServerCommands: async (serverId) => {
try {
return await api.get<SlashCommand[]>(`/servers/${serverId}/commands`);
return await api.get<SlashCommand[]>(`/bots/servers/${serverId}/commands`);
} catch (error) {
set({
error: error instanceof Error ? error.message : 'Failed to fetch server commands',
+3
View File
@@ -38,6 +38,9 @@ export interface Message {
author_id: string;
author_username: string;
author_display_name: string | null;
author_bot?: boolean;
bot_id?: string | null;
bot_name?: string | null;
content: string;
reply_to?: string | null;
embeds?: MessageEmbed[];