mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 06:28:53 +00:00
feat: Added options for load testing to automatically play music in specified channels
This commit is contained in:
1 parent
771429b595
commit
8e04d59a6a
5 files changed
+50
-3
No files matched your search
@@ -39,7 +39,7 @@ exports.createPlayer = async (client) => {
|
||||
});
|
||||
|
||||
await player.extractors.loadDefault();
|
||||
logger.debug(`[Shard ${client.shard.ids[0]}] discord-player loaded dependencies:\n${player.scanDeps()}`);
|
||||
logger.trace(`[Shard ${client.shard.ids[0]}] discord-player loaded dependencies:\n${player.scanDeps()}`);
|
||||
|
||||
return player;
|
||||
} catch (error) {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
const logger = require('../../services/logger');
|
||||
const { loadTestOptions } = require('../../config');
|
||||
|
||||
exports.startLoadTest = async (client) => {
|
||||
if (!loadTestOptions.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const channelIds = loadTestOptions.channelIdsToJoin;
|
||||
const track = loadTestOptions.trackUrl;
|
||||
logger.info(`Starting load test in ${channelIds.length} channels.`);
|
||||
|
||||
channelIds.forEach((each) => {
|
||||
client.shard.broadcastEval(
|
||||
async (shardClient, { channelId, track }) => {
|
||||
const channel = shardClient.channels.cache.get(channelId);
|
||||
if (channel) {
|
||||
/* eslint-disable no-undef */
|
||||
await player.play(channel.id, track, {
|
||||
nodeOptions: {
|
||||
leaveOnEmpty: false,
|
||||
leaveOnEnd: false,
|
||||
leaveOnStop: false,
|
||||
metadata: {
|
||||
channel: channel,
|
||||
client: shardClient
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
{ context: { channelId: each, track: track } }
|
||||
);
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user