This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from mariusbegby/load-test-functionality
Added options for load testing to automatically play music in specified channels
- Loading branch information
Showing
5 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } } | ||
); | ||
}); | ||
}; |