This commit is contained in:
tkrmagid-desktop
2026-04-11 14:22:48 +09:00
parent b329ccc03b
commit 4037afeb68
12 changed files with 200 additions and 86 deletions

View File

@@ -8,6 +8,7 @@ import { getGuildById, getVoiceChannelById } from "../utils/music/Channel";
import { channelJoin } from "../commands/join";
import { GuildPlayer } from "./GuildPlayer";
import { Guild, VoiceChannel } from "discord.js";
import { SongItem } from "../types/Track";
type SubAction =
"search" |
@@ -47,8 +48,17 @@ export class RedisClient {
if (data.action === "search") {
const resultKey = `search:${data.requestId}`;
const results = await Spotify.getSearchFull(data.query) ?? await YoutubeMusic.getSearchFull(data.query) ?? [];
await this.pub.setex(resultKey, 60, JSON.stringify(results));
const spotify: SongItem[] = (await Spotify.getSearchFull(data.query) ?? []).slice(0,10);
const youtubeMusic: SongItem[] = (await YoutubeMusic.getSearchFull(data.query) ?? []).slice(0,10);
const youtubeVideo: SongItem[] = (await lavalinkManager.youtubeSearch(data.query) ?? []).slice(0,10).map((video) => ({
videoId: video.info.identifier,
url: `https://www.youtube.com/watch?v=${video.info.identifier}`,
title: video.info.title,
artist: video.info.author,
thumbnail: video.info.artworkUrl ?? "",
duration: video.info.length,
}));
await this.pub.setex(resultKey, 60, JSON.stringify({ spotify, youtubeMusic, youtubeVideo }));
Logger.log(`[Redis Pub] [setex] 결과 저장: (${resultKey})`);
}
if (data.action === "player_play") {