feat: Added options for load testing to automatically play music in specified channels

This commit is contained in:
Marius Begby committed 2023-07-25 13:17:52 +02:00
1 parent 771429b595
commit 8e04d59a6a
5 files changed
+50 -3

No files matched your search

+35
View File
@@ -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 } }
);
});
};