All files / src/modules/bot/music/classes QueueStore.ts

0% Statements 0/7
100% Branches 0/0
0% Functions 0/7
0% Lines 0/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31                                                             
import { QueueStoreManager, StoredQueue } from "lavalink-client";
import { RedisClient } from "./RedisClient";
 
export class QueueStore implements QueueStoreManager {
	public constructor(private redis: RedisClient) {}
 
	public async get(guildId): Promise<string> {
		return await this.redis.get(this.id(guildId));
	}
 
	public async set(guildId, stringifiedQueueData): Promise<"OK"> {
		return await this.redis.set(this.id(guildId), stringifiedQueueData);
	}
 
	public async delete(guildId): Promise<number> {
		return await this.redis.del(this.id(guildId));
	}
 
	public async parse(stringifiedQueueData): Promise<Partial<StoredQueue>> {
		return JSON.parse(stringifiedQueueData);
	}
 
	public async stringify(parsedQueueData): Promise<string> {
		return JSON.stringify(parsedQueueData);
	}
 
	private id(guildId: string): string {
		return `lavalinkqueue_${guildId}`;
	}
}