| 6 | import type { AutocompleteInteraction, SlashInteraction } from "../../types/interaction.types.ts"; |
| 7 | |
| 8 | export class Parser<T extends AutocompleteInteraction | SlashInteraction> { |
| 9 | cache: Map<string, unknown> = new Map(); |
| 10 | |
| 11 | constructor(protected inter: T) { |
| 12 | } |
| 13 | |
| 14 | async getScopedQueues(): Promise<Collection<bigint, DbQueue>> { |
| 15 | const queue = await new QueueOption().get(this.inter); |
| 16 | if (queue) { |
| 17 | return new Collection([[queue.id, queue]]); |
| 18 | } |
| 19 | |
| 20 | const queues = await new QueuesOption().get(this.inter); |
| 21 | if (queues) { |
| 22 | return queues; |
| 23 | } |
| 24 | |
| 25 | return this.inter.store.dbQueues(); |
| 26 | } |
| 27 | |
| 28 | getScopedVoices(queues: Collection<bigint, DbQueue>) { |
| 29 | return this.inter.store.dbVoices().filter(voice => |
| 30 | queues.has(voice.queueId), |
| 31 | ); |
| 32 | } |
| 33 | |
| 34 | getScopedMembers(queues: Collection<bigint, DbQueue>) { |
| 35 | return this.inter.store.dbMembers().filter(member => |
| 36 | queues.has(member.queueId), |
| 37 | ); |
| 38 | } |
| 39 | |
| 40 | getScopedDisplays(queues: Collection<bigint, DbQueue>) { |
| 41 | return this.inter.store.dbDisplays().filter(display => |
| 42 | queues.has(display.queueId), |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | getScopedSchedules(queues: Collection<bigint, DbQueue>) { |
| 47 | return this.inter.store.dbSchedules().filter(schedule => |
| 48 | queues.has(schedule.queueId), |
| 49 | ); |
| 50 | } |
| 51 | |
| 52 | getScopedBlacklisted(queues: Collection<bigint, DbQueue>) { |
| 53 | return this.inter.store.dbBlacklisted().filter(blacklisted => |
| 54 | queues.has(blacklisted.queueId), |
| 55 | ); |
| 56 | } |
| 57 | |
| 58 | getScopedWhitelisted(queues: Collection<bigint, DbQueue>) { |
| 59 | return this.inter.store.dbWhitelisted().filter(whitelisted => |
| 60 | queues.has(whitelisted.queueId), |
| 61 | ); |
| 62 | } |
| 63 | |
| 64 | getScopedPrioritized(queues: Collection<bigint, DbQueue>) { |
| 65 | return this.inter.store.dbPrioritized().filter(prioritized => |
nothing calls this directly
no outgoing calls
no test coverage detected