magmastream 2.9.0-dev.2 → 2.9.0-dev.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.ts +169 -46
- package/dist/storage/CollectionPlayerStore.js +77 -0
- package/dist/storage/RedisPlayerStore.js +156 -0
- package/dist/structures/Manager.js +419 -179
- package/dist/structures/Node.js +47 -38
- package/dist/structures/Player.js +59 -55
- package/dist/structures/Queue.js +92 -32
- package/dist/structures/RedisQueue.js +309 -0
- package/dist/structures/Utils.js +400 -343
- package/dist/utils/managerCheck.js +8 -5
- package/package.json +12 -11
package/README.md
CHANGED
|
@@ -95,12 +95,12 @@
|
|
|
95
95
|
| [Stal](https://discord.com/oauth2/authorize?client_id=923938180263182356&scope=bot%20applications.commands&permissions=27648861246) | memte |
|
|
96
96
|
| [Lunio](https://discord.com/api/oauth2/authorize?client_id=945030475779551415&permissions=61991952&scope=bot+applications.commands) | vexi |
|
|
97
97
|
| [JukeDisc](https://discord.com/oauth2/authorize?client_id=1109751797549105176&permissions=968552214080&scope=bot+applications.commands) | Theo |
|
|
98
|
-
| [
|
|
98
|
+
| [Leo](https://discord.com/oauth2/authorize?client_id=923529398425096193&permissions=12888394808&scope=bot%20identify%20applications.commands) | Itz Random |
|
|
99
99
|
| [Soundy](https://dsc.gg/sndy) | iaMJ |
|
|
100
100
|
| [HamBot](https://discord.com/oauth2/authorize?client_id=1049314312776335390) | yanishamburger|
|
|
101
101
|
| [Miyu](https://discord.com/oauth2/authorize?client_id=1277180179273482280&permissions=572851999731703&response_type=code&redirect_uri=https%3A%2F%2Fdiscord.gg%2Ftn3nbFB8nX&integration_type=0&scope=identify+applications.commands+bot) | Kenver |
|
|
102
102
|
| [Savage Bot](https://discord.com/oauth2/authorize?client_id=823703707522433054&permissions=8&scope=bot%20applications.commands) | Savage
|
|
103
|
-
| [
|
|
103
|
+
| [lost](https://discord.com/oauth2/authorize?client_id=1280681209604739204) | pomice
|
|
104
104
|
|
|
105
105
|
|
|
106
106
|
Want to showcase your bot? Feel free to create a pull request and add it to our growing list of amazing bots powered by Magmastream!
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { User, ClientUser, Message } from 'discord.js';
|
|
|
2
2
|
import WebSocket from 'ws';
|
|
3
3
|
import { Collection } from '@discordjs/collection';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
|
+
import { Redis } from 'ioredis';
|
|
5
6
|
|
|
6
7
|
/** Represents an equalizer band. */
|
|
7
8
|
interface Band {
|
|
@@ -573,24 +574,7 @@ interface Lyrics {
|
|
|
573
574
|
/**
|
|
574
575
|
* The player's queue, the `current` property is the currently playing track, think of the rest as the up-coming tracks.
|
|
575
576
|
*/
|
|
576
|
-
declare class Queue extends Array<Track> {
|
|
577
|
-
/**
|
|
578
|
-
* The total duration of the queue in milliseconds.
|
|
579
|
-
* This includes the duration of the currently playing track.
|
|
580
|
-
*/
|
|
581
|
-
get duration(): number;
|
|
582
|
-
/**
|
|
583
|
-
* The total size of tracks in the queue including the current track.
|
|
584
|
-
* This includes the current track if it is not null.
|
|
585
|
-
* @returns The total size of tracks in the queue including the current track.
|
|
586
|
-
*/
|
|
587
|
-
get totalSize(): number;
|
|
588
|
-
/**
|
|
589
|
-
* The size of tracks in the queue.
|
|
590
|
-
* This does not include the currently playing track.
|
|
591
|
-
* @returns The size of tracks in the queue.
|
|
592
|
-
*/
|
|
593
|
-
get size(): number;
|
|
577
|
+
declare class Queue extends Array<Track> implements IQueue {
|
|
594
578
|
/** The current track */
|
|
595
579
|
current: Track | null;
|
|
596
580
|
/** The previous tracks */
|
|
@@ -605,12 +589,36 @@ declare class Queue extends Array<Track> {
|
|
|
605
589
|
* @param manager The Manager instance.
|
|
606
590
|
*/
|
|
607
591
|
constructor(guildId: string, manager: Manager);
|
|
592
|
+
getCurrent(): Promise<Track | null>;
|
|
593
|
+
setCurrent(track: Track | null): Promise<void>;
|
|
594
|
+
getPrevious(): Promise<Track[]>;
|
|
595
|
+
addPrevious(track: Track | Track[]): Promise<void>;
|
|
596
|
+
setPrevious(tracks: Track[]): Promise<void>;
|
|
597
|
+
popPrevious(): Promise<Track | null>;
|
|
598
|
+
clearPrevious(): Promise<void>;
|
|
599
|
+
/**
|
|
600
|
+
* The total duration of the queue in milliseconds.
|
|
601
|
+
* This includes the duration of the currently playing track.
|
|
602
|
+
*/
|
|
603
|
+
duration(): Promise<number>;
|
|
604
|
+
/**
|
|
605
|
+
* The total size of tracks in the queue including the current track.
|
|
606
|
+
* This includes the current track if it is not null.
|
|
607
|
+
* @returns The total size of tracks in the queue including the current track.
|
|
608
|
+
*/
|
|
609
|
+
totalSize(): Promise<number>;
|
|
610
|
+
/**
|
|
611
|
+
* The size of tracks in the queue.
|
|
612
|
+
* This does not include the currently playing track.
|
|
613
|
+
* @returns The size of tracks in the queue.
|
|
614
|
+
*/
|
|
615
|
+
size(): Promise<number>;
|
|
608
616
|
/**
|
|
609
617
|
* Adds a track to the queue.
|
|
610
618
|
* @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
|
|
611
619
|
* @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
|
|
612
620
|
*/
|
|
613
|
-
add(track: Track | Track[], offset?: number): void
|
|
621
|
+
add(track: Track | Track[], offset?: number): Promise<void>;
|
|
614
622
|
/**
|
|
615
623
|
* Removes track(s) from the queue.
|
|
616
624
|
* @param startOrPosition If a single number is provided, it will be treated as the position of the track to remove.
|
|
@@ -618,26 +626,36 @@ declare class Queue extends Array<Track> {
|
|
|
618
626
|
* @param end Optional, end of the range of tracks to remove.
|
|
619
627
|
* @returns The removed track(s).
|
|
620
628
|
*/
|
|
621
|
-
remove(position?: number): Track[]
|
|
622
|
-
remove(start: number, end: number): Track[]
|
|
629
|
+
remove(position?: number): Promise<Track[]>;
|
|
630
|
+
remove(start: number, end: number): Promise<Track[]>;
|
|
623
631
|
/**
|
|
624
632
|
* Clears the queue.
|
|
625
633
|
* This will remove all tracks from the queue and emit a state update event.
|
|
626
634
|
*/
|
|
627
|
-
clear(): void
|
|
635
|
+
clear(): Promise<void>;
|
|
628
636
|
/**
|
|
629
637
|
* Shuffles the queue.
|
|
630
638
|
* This will randomize the order of the tracks in the queue and emit a state update event.
|
|
631
639
|
*/
|
|
632
|
-
shuffle(): void
|
|
640
|
+
shuffle(): Promise<void>;
|
|
633
641
|
/**
|
|
634
642
|
* Shuffles the queue to play tracks requested by each user one block at a time.
|
|
635
643
|
*/
|
|
636
|
-
userBlockShuffle(): void
|
|
644
|
+
userBlockShuffle(): Promise<void>;
|
|
637
645
|
/**
|
|
638
646
|
* Shuffles the queue to play tracks requested by each user one by one.
|
|
639
647
|
*/
|
|
640
|
-
roundRobinShuffle(): void
|
|
648
|
+
roundRobinShuffle(): Promise<void>;
|
|
649
|
+
dequeue(): Promise<Track | undefined>;
|
|
650
|
+
enqueueFront(track: Track | Track[]): Promise<void>;
|
|
651
|
+
getTracks(): Promise<Track[]>;
|
|
652
|
+
getSlice(start?: number, end?: number): Promise<Track[]>;
|
|
653
|
+
modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise<Track[]>;
|
|
654
|
+
mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>;
|
|
655
|
+
filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track[]>;
|
|
656
|
+
findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>;
|
|
657
|
+
someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
|
|
658
|
+
everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
|
|
641
659
|
}
|
|
642
660
|
|
|
643
661
|
declare abstract class TrackUtils {
|
|
@@ -678,11 +696,26 @@ declare abstract class AutoPlayUtils {
|
|
|
678
696
|
* @hidden
|
|
679
697
|
*/
|
|
680
698
|
static init(manager: Manager): void;
|
|
681
|
-
|
|
699
|
+
/**
|
|
700
|
+
* Gets recommended tracks for the given track.
|
|
701
|
+
* @param track The track to get recommended tracks for.
|
|
702
|
+
* @returns An array of recommended tracks.
|
|
703
|
+
*/
|
|
704
|
+
static getRecommendedTracks(track: Track): Promise<Track[]>;
|
|
705
|
+
/**
|
|
706
|
+
* Gets recommended tracks from Last.fm for the given track.
|
|
707
|
+
* @param track The track to get recommended tracks for.
|
|
708
|
+
* @param apiKey The API key for Last.fm.
|
|
709
|
+
* @returns An array of recommended tracks.
|
|
710
|
+
*/
|
|
682
711
|
static getRecommendedTracksFromLastFm(track: Track, apiKey: string): Promise<Track[]>;
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
712
|
+
/**
|
|
713
|
+
* Gets recommended tracks from the given source.
|
|
714
|
+
* @param track The track to get recommended tracks for.
|
|
715
|
+
* @param platform The source to get recommended tracks from.
|
|
716
|
+
* @returns An array of recommended tracks.
|
|
717
|
+
*/
|
|
718
|
+
static getRecommendedTracksFromSource(track: Track, platform: string): Promise<Track[]>;
|
|
686
719
|
}
|
|
687
720
|
/** Gets or extends structures to extend the built in, or already extended, classes to add more functionality. */
|
|
688
721
|
declare abstract class Structure {
|
|
@@ -883,6 +916,35 @@ interface PlayerUpdate {
|
|
|
883
916
|
ping: number;
|
|
884
917
|
};
|
|
885
918
|
}
|
|
919
|
+
interface IQueue {
|
|
920
|
+
getCurrent(): Promise<Track | null>;
|
|
921
|
+
setCurrent(track: Track | null): Promise<void>;
|
|
922
|
+
getPrevious(): Promise<Track[]>;
|
|
923
|
+
addPrevious(track: Track | Track[]): Promise<void>;
|
|
924
|
+
setPrevious(track: Track | Track[]): Promise<void>;
|
|
925
|
+
/** Get newest track (index 0) */
|
|
926
|
+
popPrevious(): Promise<Track | null>;
|
|
927
|
+
clearPrevious(): Promise<void>;
|
|
928
|
+
size(): Promise<number>;
|
|
929
|
+
totalSize(): Promise<number>;
|
|
930
|
+
duration(): Promise<number>;
|
|
931
|
+
add(track: Track | Track[], offset?: number): Promise<void>;
|
|
932
|
+
remove(start?: number, end?: number): Promise<Track[]>;
|
|
933
|
+
clear(): Promise<void>;
|
|
934
|
+
dequeue(): Promise<Track | undefined>;
|
|
935
|
+
enqueueFront(track: Track | Track[]): Promise<void>;
|
|
936
|
+
getTracks(): Promise<Track[]>;
|
|
937
|
+
getSlice(start?: number, end?: number): Promise<Track[]>;
|
|
938
|
+
modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise<Track[]>;
|
|
939
|
+
shuffle(): Promise<void>;
|
|
940
|
+
userBlockShuffle(): Promise<void>;
|
|
941
|
+
roundRobinShuffle(): Promise<void>;
|
|
942
|
+
mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>;
|
|
943
|
+
filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track[]>;
|
|
944
|
+
findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>;
|
|
945
|
+
someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
|
|
946
|
+
everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
|
|
947
|
+
}
|
|
886
948
|
|
|
887
949
|
/**
|
|
888
950
|
* The main hub for interacting with Lavalink and using Magmastream,
|
|
@@ -895,13 +957,14 @@ declare class Manager extends EventEmitter {
|
|
|
895
957
|
/** The options that were set. */
|
|
896
958
|
readonly options: ManagerOptions;
|
|
897
959
|
initiated: boolean;
|
|
960
|
+
redis?: Redis;
|
|
898
961
|
/**
|
|
899
962
|
* Initiates the Manager class.
|
|
900
963
|
* @param options
|
|
901
964
|
* @param options.enabledPlugins - An array of enabledPlugins to load.
|
|
902
965
|
* @param options.nodes - An array of node options to create nodes from.
|
|
903
966
|
* @param options.playNextOnEnd - Whether to automatically play the first track in the queue when the player is created.
|
|
904
|
-
* @param options.
|
|
967
|
+
* @param options.autoPlaySearchPlatforms - The search platform autoplay will use. Fallback to Youtube if not found.
|
|
905
968
|
* @param options.enablePriorityMode - Whether to use the priority when selecting a node to play on.
|
|
906
969
|
* @param options.clientName - The name of the client to send to Lavalink.
|
|
907
970
|
* @param options.defaultSearchPlatform - The default search platform to use when searching for tracks.
|
|
@@ -926,17 +989,24 @@ declare class Manager extends EventEmitter {
|
|
|
926
989
|
*/
|
|
927
990
|
search<T = unknown>(query: string | SearchQuery, requester?: T): Promise<SearchResult>;
|
|
928
991
|
/**
|
|
929
|
-
*
|
|
930
|
-
* @param
|
|
931
|
-
* @returns The
|
|
992
|
+
* Returns a player or undefined if it does not exist.
|
|
993
|
+
* @param guildId The guild ID of the player to retrieve.
|
|
994
|
+
* @returns The player if it exists, undefined otherwise.
|
|
932
995
|
*/
|
|
933
|
-
|
|
996
|
+
getPlayer(guildId: string): Player | undefined;
|
|
934
997
|
/**
|
|
998
|
+
* @deprecated - Will be removed with v2.10.0 use {@link getPlayer} instead
|
|
935
999
|
* Returns a player or undefined if it does not exist.
|
|
936
1000
|
* @param guildId The guild ID of the player to retrieve.
|
|
937
1001
|
* @returns The player if it exists, undefined otherwise.
|
|
938
1002
|
*/
|
|
939
|
-
get(guildId: string): Player | undefined
|
|
1003
|
+
get(guildId: string): Promise<Player | undefined>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Creates a player or returns one if it already exists.
|
|
1006
|
+
* @param options The options to create the player with.
|
|
1007
|
+
* @returns The created player.
|
|
1008
|
+
*/
|
|
1009
|
+
create(options: PlayerOptions): Player;
|
|
940
1010
|
/**
|
|
941
1011
|
* Destroys a player.
|
|
942
1012
|
* @param guildId The guild ID of the player to destroy.
|
|
@@ -990,6 +1060,12 @@ declare class Manager extends EventEmitter {
|
|
|
990
1060
|
* @param {string} guildId - The guild ID of the player to save
|
|
991
1061
|
*/
|
|
992
1062
|
savePlayerState(guildId: string): Promise<void>;
|
|
1063
|
+
/**
|
|
1064
|
+
* Sleeps for a specified amount of time.
|
|
1065
|
+
* @param ms The amount of time to sleep in milliseconds.
|
|
1066
|
+
* @returns A promise that resolves after the specified amount of time.
|
|
1067
|
+
*/
|
|
1068
|
+
private sleep;
|
|
993
1069
|
/**
|
|
994
1070
|
* Loads player states from the JSON file.
|
|
995
1071
|
* @param nodeId The ID of the node to load player states from.
|
|
@@ -1072,7 +1148,7 @@ declare class Manager extends EventEmitter {
|
|
|
1072
1148
|
* @param player The Player instance to serialize
|
|
1073
1149
|
* @returns The serialized Player instance
|
|
1074
1150
|
*/
|
|
1075
|
-
|
|
1151
|
+
serializePlayer(player: Player): Record<string, unknown>;
|
|
1076
1152
|
/**
|
|
1077
1153
|
* Checks for players that are no longer active and deletes their saved state files.
|
|
1078
1154
|
* This is done to prevent stale state files from accumulating on the file system.
|
|
@@ -1114,13 +1190,19 @@ interface Payload {
|
|
|
1114
1190
|
};
|
|
1115
1191
|
}
|
|
1116
1192
|
interface ManagerOptions {
|
|
1193
|
+
/** The state storage options.
|
|
1194
|
+
*
|
|
1195
|
+
* @default { type: StateStorageType.Collection }
|
|
1196
|
+
*/
|
|
1197
|
+
stateStorage?: StateStorageOptions;
|
|
1117
1198
|
/** Enable priority mode over least player count or load balancing? */
|
|
1118
1199
|
enablePriorityMode?: boolean;
|
|
1119
1200
|
/** Automatically play the next track when the current one ends. */
|
|
1120
1201
|
playNextOnEnd?: boolean;
|
|
1121
|
-
/**
|
|
1122
|
-
* Use enum `
|
|
1123
|
-
|
|
1202
|
+
/** An array of search platforms to use for autoplay. First to last matters
|
|
1203
|
+
* Use enum `AutoPlayPlatform`.
|
|
1204
|
+
*/
|
|
1205
|
+
autoPlaySearchPlatforms?: AutoPlayPlatform[];
|
|
1124
1206
|
/** The client ID to use. */
|
|
1125
1207
|
clientId?: string;
|
|
1126
1208
|
/** Value to use for the `Client-Name` header. */
|
|
@@ -1135,7 +1217,7 @@ interface ManagerOptions {
|
|
|
1135
1217
|
/** The last.fm API key.
|
|
1136
1218
|
* If you need to create one go here: https://www.last.fm/api/account/create.
|
|
1137
1219
|
* If you already have one, get it from here: https://www.last.fm/api/accounts. */
|
|
1138
|
-
lastFmApiKey
|
|
1220
|
+
lastFmApiKey?: string;
|
|
1139
1221
|
/** The maximum number of previous tracks to store. */
|
|
1140
1222
|
maxPreviousTracks?: number;
|
|
1141
1223
|
/** The array of nodes to connect to. */
|
|
@@ -1153,6 +1235,21 @@ interface ManagerOptions {
|
|
|
1153
1235
|
*/
|
|
1154
1236
|
send(id: string, payload: Payload): void;
|
|
1155
1237
|
}
|
|
1238
|
+
interface RedisConfig {
|
|
1239
|
+
host: string;
|
|
1240
|
+
port: string;
|
|
1241
|
+
password?: string;
|
|
1242
|
+
db?: number;
|
|
1243
|
+
prefix?: string;
|
|
1244
|
+
}
|
|
1245
|
+
declare enum StateStorageType {
|
|
1246
|
+
Collection = "collection",
|
|
1247
|
+
Redis = "redis"
|
|
1248
|
+
}
|
|
1249
|
+
interface StateStorageOptions {
|
|
1250
|
+
type: StateStorageType;
|
|
1251
|
+
redisConfig?: RedisConfig;
|
|
1252
|
+
}
|
|
1156
1253
|
declare enum TrackPartial {
|
|
1157
1254
|
/** The base64 encoded string of the track */
|
|
1158
1255
|
Track = "track",
|
|
@@ -1195,6 +1292,7 @@ declare enum SearchPlatform {
|
|
|
1195
1292
|
Bandcamp = "bcsearch",
|
|
1196
1293
|
Deezer = "dzsearch",
|
|
1197
1294
|
Jiosaavn = "jssearch",
|
|
1295
|
+
Qobuz = "qbsearch",
|
|
1198
1296
|
SoundCloud = "scsearch",
|
|
1199
1297
|
Spotify = "spsearch",
|
|
1200
1298
|
Tidal = "tdsearch",
|
|
@@ -1202,6 +1300,15 @@ declare enum SearchPlatform {
|
|
|
1202
1300
|
YouTube = "ytsearch",
|
|
1203
1301
|
YouTubeMusic = "ytmsearch"
|
|
1204
1302
|
}
|
|
1303
|
+
declare enum AutoPlayPlatform {
|
|
1304
|
+
Spotify = "spotify",
|
|
1305
|
+
Deezer = "deezer",
|
|
1306
|
+
SoundCloud = "soundcloud",
|
|
1307
|
+
Tidal = "tidal",
|
|
1308
|
+
VKMusic = "vkmusic",
|
|
1309
|
+
Qobuz = "qobuz",
|
|
1310
|
+
YouTube = "youtube"
|
|
1311
|
+
}
|
|
1205
1312
|
declare enum PlayerStateEventTypes {
|
|
1206
1313
|
AutoPlayChange = "playerAutoplay",
|
|
1207
1314
|
ConnectionChange = "playerConnection",
|
|
@@ -1360,11 +1467,27 @@ interface ManagerEvents {
|
|
|
1360
1467
|
[ManagerEventTypes.ChapterStarted]: [player: Player, track: Track, payload: SponsorBlockChapterStarted];
|
|
1361
1468
|
[ManagerEventTypes.ChaptersLoaded]: [player: Player, track: Track, payload: SponsorBlockChaptersLoaded];
|
|
1362
1469
|
}
|
|
1470
|
+
interface PlayerStore {
|
|
1471
|
+
get(guildId: string): Promise<Player | undefined>;
|
|
1472
|
+
set(guildId: string, player: Player): Promise<void>;
|
|
1473
|
+
delete(guildId: string): Promise<void>;
|
|
1474
|
+
keys(): Promise<string[]>;
|
|
1475
|
+
has(guildId: string): Promise<boolean>;
|
|
1476
|
+
filter(predicate: (player: Player, guildId: string) => boolean | Promise<boolean>): Promise<Map<string, Player>>;
|
|
1477
|
+
find(predicate: (player: Player, guildId: string) => boolean | Promise<boolean>): Promise<Player | undefined>;
|
|
1478
|
+
map<T>(callback: (player: Player, guildId: string) => T | Promise<T>): Promise<T[]>;
|
|
1479
|
+
forEach(callback: (player: Player, guildId: string) => void | Promise<void>): Promise<void>;
|
|
1480
|
+
some(predicate: (player: Player, guildId: string) => boolean | Promise<boolean>): Promise<boolean>;
|
|
1481
|
+
every(predicate: (player: Player, guildId: string) => boolean | Promise<boolean>): Promise<boolean>;
|
|
1482
|
+
size(): Promise<number>;
|
|
1483
|
+
clear(): Promise<void>;
|
|
1484
|
+
entries(): AsyncIterableIterator<[string, Player]>;
|
|
1485
|
+
}
|
|
1363
1486
|
|
|
1364
1487
|
declare class Player {
|
|
1365
1488
|
options: PlayerOptions;
|
|
1366
1489
|
/** The Queue for the Player. */
|
|
1367
|
-
|
|
1490
|
+
queue: IQueue;
|
|
1368
1491
|
/** The filters applied to the audio. */
|
|
1369
1492
|
filters: Filters;
|
|
1370
1493
|
/** Whether the queue repeats the track. */
|
|
@@ -1402,11 +1525,11 @@ declare class Player {
|
|
|
1402
1525
|
/** The autoplay state of the player. */
|
|
1403
1526
|
isAutoplay: boolean;
|
|
1404
1527
|
/** The number of times to try autoplay before emitting queueEnd. */
|
|
1405
|
-
autoplayTries: number
|
|
1528
|
+
autoplayTries: number;
|
|
1406
1529
|
private static _manager;
|
|
1407
1530
|
private readonly data;
|
|
1408
1531
|
private dynamicLoopInterval;
|
|
1409
|
-
|
|
1532
|
+
dynamicRepeatIntervalMs: number | null;
|
|
1410
1533
|
/**
|
|
1411
1534
|
* Creates a new player, returns one if it already exists.
|
|
1412
1535
|
* @param options The player options.
|
|
@@ -1569,7 +1692,7 @@ declare class Player {
|
|
|
1569
1692
|
* @throws {TypeError} If the repeat parameter is not a boolean.
|
|
1570
1693
|
* @throws {RangeError} If the queue size is less than or equal to 1.
|
|
1571
1694
|
*/
|
|
1572
|
-
setDynamicRepeat(repeat: boolean, ms: number): this
|
|
1695
|
+
setDynamicRepeat(repeat: boolean, ms: number): Promise<this>;
|
|
1573
1696
|
/**
|
|
1574
1697
|
* Restarts the currently playing track from the beginning.
|
|
1575
1698
|
* If there is no track playing, it will play the next track in the queue.
|
|
@@ -2136,5 +2259,5 @@ declare class Plugin {
|
|
|
2136
2259
|
load(manager: Manager): void;
|
|
2137
2260
|
}
|
|
2138
2261
|
|
|
2139
|
-
export { AutoPlayUtils, AvailableFilters, Filters, LoadTypes, Manager, ManagerEventTypes, Node, Player, PlayerStateEventTypes, Plugin, Queue, Rest, SearchPlatform, SeverityTypes, SponsorBlockSegment, StateTypes, Structure, TrackEndReasonTypes, TrackPartial, TrackSourceTypes, TrackUtils, UseNodeOptions };
|
|
2140
|
-
export type { CPUStats, EqualizerBand, Exception, Extendable, FrameStats, LavalinkInfo, LavalinkResponse, LoadType, Lyrics, LyricsLine, ManagerEvents, ManagerOptions, MemoryStats, NodeMessage, NodeOptions, NodeStats, Payload, PlayOptions, PlayerEvent, PlayerEventType, PlayerEvents, PlayerOptions, PlayerUpdate, PlaylistData, PlaylistInfoData, PlaylistRawData, SearchQuery, SearchResult, Severity, Sizes, SponsorBlockChapterStarted, SponsorBlockChaptersLoaded, SponsorBlockSegmentEventType, SponsorBlockSegmentEvents, SponsorBlockSegmentSkipped, SponsorBlockSegmentsLoaded, State, Track, TrackData, TrackDataInfo, TrackEndEvent, TrackEndReason, TrackExceptionEvent, TrackPluginInfo, TrackSourceName, TrackStartEvent, TrackStuckEvent, UseNodeOption, VoicePacket, VoiceServer, VoiceState, WebSocketClosedEvent };
|
|
2262
|
+
export { AutoPlayPlatform, AutoPlayUtils, AvailableFilters, Filters, LoadTypes, Manager, ManagerEventTypes, Node, Player, PlayerStateEventTypes, Plugin, Queue, Rest, SearchPlatform, SeverityTypes, SponsorBlockSegment, StateStorageType, StateTypes, Structure, TrackEndReasonTypes, TrackPartial, TrackSourceTypes, TrackUtils, UseNodeOptions };
|
|
2263
|
+
export type { CPUStats, EqualizerBand, Exception, Extendable, FrameStats, IQueue, LavalinkInfo, LavalinkResponse, LoadType, Lyrics, LyricsLine, ManagerEvents, ManagerOptions, MemoryStats, NodeMessage, NodeOptions, NodeStats, Payload, PlayOptions, PlayerEvent, PlayerEventType, PlayerEvents, PlayerOptions, PlayerStore, PlayerUpdate, PlaylistData, PlaylistInfoData, PlaylistRawData, RedisConfig, SearchQuery, SearchResult, Severity, Sizes, SponsorBlockChapterStarted, SponsorBlockChaptersLoaded, SponsorBlockSegmentEventType, SponsorBlockSegmentEvents, SponsorBlockSegmentSkipped, SponsorBlockSegmentsLoaded, State, StateStorageOptions, Track, TrackData, TrackDataInfo, TrackEndEvent, TrackEndReason, TrackExceptionEvent, TrackPluginInfo, TrackSourceName, TrackStartEvent, TrackStuckEvent, UseNodeOption, VoicePacket, VoiceServer, VoiceState, WebSocketClosedEvent };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// THIS WILL BE REMOVED IF YOU DONT FIND A USE FOR IT.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.CollectionPlayerStore = void 0;
|
|
5
|
+
const collection_1 = require("@discordjs/collection");
|
|
6
|
+
class CollectionPlayerStore {
|
|
7
|
+
store = new collection_1.Collection();
|
|
8
|
+
async get(guildId) {
|
|
9
|
+
return this.store.get(guildId);
|
|
10
|
+
}
|
|
11
|
+
async set(guildId, player) {
|
|
12
|
+
this.store.set(guildId, player);
|
|
13
|
+
}
|
|
14
|
+
async delete(guildId) {
|
|
15
|
+
this.store.delete(guildId);
|
|
16
|
+
}
|
|
17
|
+
async keys() {
|
|
18
|
+
return [...this.store.keys()];
|
|
19
|
+
}
|
|
20
|
+
async has(guildId) {
|
|
21
|
+
return this.store.has(guildId);
|
|
22
|
+
}
|
|
23
|
+
async filter(predicate) {
|
|
24
|
+
const result = new Map();
|
|
25
|
+
for (const [guildId, player] of this.store.entries()) {
|
|
26
|
+
if (await predicate(player, guildId)) {
|
|
27
|
+
result.set(guildId, player);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
async find(predicate) {
|
|
33
|
+
for (const [guildId, player] of this.store.entries()) {
|
|
34
|
+
if (await predicate(player, guildId))
|
|
35
|
+
return player;
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
async map(callback) {
|
|
40
|
+
const results = [];
|
|
41
|
+
for (const [guildId, player] of this.store.entries()) {
|
|
42
|
+
results.push(await callback(player, guildId));
|
|
43
|
+
}
|
|
44
|
+
return results;
|
|
45
|
+
}
|
|
46
|
+
async forEach(callback) {
|
|
47
|
+
for (const [guildId, player] of this.store.entries()) {
|
|
48
|
+
await callback(player, guildId);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async some(predicate) {
|
|
52
|
+
for (const [guildId, player] of this.store.entries()) {
|
|
53
|
+
if (await predicate(player, guildId))
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
async every(predicate) {
|
|
59
|
+
for (const [guildId, player] of this.store.entries()) {
|
|
60
|
+
if (!(await predicate(player, guildId)))
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
async size() {
|
|
66
|
+
return this.store.size;
|
|
67
|
+
}
|
|
68
|
+
async clear() {
|
|
69
|
+
this.store.clear();
|
|
70
|
+
}
|
|
71
|
+
async *entries() {
|
|
72
|
+
for (const entry of this.store.entries()) {
|
|
73
|
+
yield entry;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.CollectionPlayerStore = CollectionPlayerStore;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// THIS WILL BE REMOVED IF YOU DONT FIND A USE FOR IT.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.RedisPlayerStore = void 0;
|
|
5
|
+
class RedisPlayerStore {
|
|
6
|
+
redis;
|
|
7
|
+
manager;
|
|
8
|
+
prefix;
|
|
9
|
+
constructor(redis, manager, prefix = "magmastream:") {
|
|
10
|
+
this.redis = redis;
|
|
11
|
+
this.manager = manager;
|
|
12
|
+
this.prefix = prefix;
|
|
13
|
+
}
|
|
14
|
+
getKey(guildId) {
|
|
15
|
+
return `${this.prefix}player:${guildId}`;
|
|
16
|
+
}
|
|
17
|
+
async get(guildId) {
|
|
18
|
+
const raw = await this.redis.get(this.getKey(guildId));
|
|
19
|
+
if (!raw)
|
|
20
|
+
return undefined;
|
|
21
|
+
return JSON.parse(raw);
|
|
22
|
+
}
|
|
23
|
+
async set(guildId, player) {
|
|
24
|
+
const serialized = this.manager.serializePlayer(player);
|
|
25
|
+
await this.redis.set(this.getKey(guildId), JSON.stringify(serialized));
|
|
26
|
+
}
|
|
27
|
+
async delete(guildId) {
|
|
28
|
+
await this.redis.del(this.getKey(guildId));
|
|
29
|
+
}
|
|
30
|
+
async keys() {
|
|
31
|
+
const keys = await this.redis.keys(`${this.prefix}player:*`);
|
|
32
|
+
return keys.map((key) => key.replace(`${this.prefix}player:`, ""));
|
|
33
|
+
}
|
|
34
|
+
async has(guildId) {
|
|
35
|
+
return (await this.redis.exists(this.getKey(guildId))) === 1;
|
|
36
|
+
}
|
|
37
|
+
async filter(predicate) {
|
|
38
|
+
const keys = await this.keys();
|
|
39
|
+
const pipeline = this.redis.pipeline();
|
|
40
|
+
for (const guildId of keys) {
|
|
41
|
+
pipeline.get(this.getKey(guildId));
|
|
42
|
+
}
|
|
43
|
+
const results = await pipeline.exec();
|
|
44
|
+
const result = new Map();
|
|
45
|
+
for (let i = 0; i < results.length; i++) {
|
|
46
|
+
const [err, raw] = results[i];
|
|
47
|
+
if (err || typeof raw !== "string")
|
|
48
|
+
continue;
|
|
49
|
+
const guildId = keys[i];
|
|
50
|
+
const player = JSON.parse(raw);
|
|
51
|
+
if (await predicate(player, guildId)) {
|
|
52
|
+
result.set(guildId, player);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
async find(predicate) {
|
|
58
|
+
for (const guildId of await this.keys()) {
|
|
59
|
+
const raw = await this.redis.get(this.getKey(guildId));
|
|
60
|
+
if (!raw)
|
|
61
|
+
continue;
|
|
62
|
+
const parsed = JSON.parse(raw);
|
|
63
|
+
if (await predicate(parsed, guildId))
|
|
64
|
+
return parsed;
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
async map(callback) {
|
|
69
|
+
const keys = await this.keys();
|
|
70
|
+
if (!keys.length)
|
|
71
|
+
return [];
|
|
72
|
+
const pipeline = this.redis.pipeline();
|
|
73
|
+
for (const guildId of keys) {
|
|
74
|
+
pipeline.get(this.getKey(guildId));
|
|
75
|
+
}
|
|
76
|
+
const results = await pipeline.exec();
|
|
77
|
+
const output = [];
|
|
78
|
+
for (let i = 0; i < results.length; i++) {
|
|
79
|
+
const [err, raw] = results[i];
|
|
80
|
+
if (err || typeof raw !== "string")
|
|
81
|
+
continue;
|
|
82
|
+
const guildId = keys[i];
|
|
83
|
+
const player = JSON.parse(raw);
|
|
84
|
+
output.push(await callback(player, guildId));
|
|
85
|
+
}
|
|
86
|
+
return output;
|
|
87
|
+
}
|
|
88
|
+
async forEach(callback) {
|
|
89
|
+
for (const guildId of await this.keys()) {
|
|
90
|
+
const raw = await this.redis.get(this.getKey(guildId));
|
|
91
|
+
if (!raw)
|
|
92
|
+
continue;
|
|
93
|
+
const parsed = JSON.parse(raw);
|
|
94
|
+
await callback(parsed, guildId);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async some(predicate) {
|
|
98
|
+
const keys = await this.keys();
|
|
99
|
+
if (!keys.length)
|
|
100
|
+
return false;
|
|
101
|
+
const pipeline = this.redis.pipeline();
|
|
102
|
+
for (const guildId of keys) {
|
|
103
|
+
pipeline.get(this.getKey(guildId));
|
|
104
|
+
}
|
|
105
|
+
const results = await pipeline.exec();
|
|
106
|
+
for (let i = 0; i < results.length; i++) {
|
|
107
|
+
const [err, raw] = results[i];
|
|
108
|
+
if (err || typeof raw !== "string")
|
|
109
|
+
continue;
|
|
110
|
+
const guildId = keys[i];
|
|
111
|
+
const player = JSON.parse(raw);
|
|
112
|
+
if (await predicate(player, guildId))
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
async every(predicate) {
|
|
118
|
+
const keys = await this.keys();
|
|
119
|
+
if (!keys.length)
|
|
120
|
+
return true;
|
|
121
|
+
const pipeline = this.redis.pipeline();
|
|
122
|
+
for (const guildId of keys) {
|
|
123
|
+
pipeline.get(this.getKey(guildId));
|
|
124
|
+
}
|
|
125
|
+
const results = await pipeline.exec();
|
|
126
|
+
for (let i = 0; i < results.length; i++) {
|
|
127
|
+
const [err, raw] = results[i];
|
|
128
|
+
if (err || typeof raw !== "string")
|
|
129
|
+
continue;
|
|
130
|
+
const guildId = keys[i];
|
|
131
|
+
const player = JSON.parse(raw);
|
|
132
|
+
if (!(await predicate(player, guildId)))
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
async size() {
|
|
138
|
+
const keys = await this.keys();
|
|
139
|
+
return keys.length;
|
|
140
|
+
}
|
|
141
|
+
async clear() {
|
|
142
|
+
const keys = await this.redis.keys(`${this.prefix}player:*`);
|
|
143
|
+
if (keys.length) {
|
|
144
|
+
await this.redis.del(...keys);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async *entries() {
|
|
148
|
+
for (const guildId of await this.keys()) {
|
|
149
|
+
const raw = await this.redis.get(this.getKey(guildId));
|
|
150
|
+
if (!raw)
|
|
151
|
+
continue;
|
|
152
|
+
yield [guildId, JSON.parse(raw)];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.RedisPlayerStore = RedisPlayerStore;
|