Code Duplication    Length = 20-20 lines in 3 locations

src/Plugins/onVoice/horn.php 1 location

@@ 13-32 (lines=20) @@
10
use Monolog\Logger;
11
use Sovereign\Lib\cURL;
12
13
class horn
14
{
15
    public function run(Message $message, Discord $discord, WebSocket $webSocket, Logger $log, &$audioStreams, Channel $channel, cURL $curl)
16
    {
17
        $webSocket->joinVoiceChannel($channel)->then(function (VoiceClient $vc) use ($message, $discord, $webSocket, $log, &$audioStreams, $channel) {
18
            $guildID = $message->getChannelAttribute()->guild_id;
19
            // Add this audio stream to the array of audio streams
20
            $audioStreams[$guildID] = $vc;
21
            $vc->setFrameSize(40)->then(function () use ($vc, &$audioStreams, $guildID) {
22
                $vc->setBitrate(128000);
23
                $number = mt_rand(1, 6);
24
                $file = __DIR__ . "/../../../sounds/horns/{$number}.mp3";
25
                $vc->playFile($file, 2)->done(function () use ($vc, &$audioStreams, $guildID) {
26
                    unset($audioStreams[$guildID]);
27
                    $vc->close();
28
                });
29
            });
30
        });
31
    }
32
}
33

src/Plugins/onVoice/reapers.php 1 location

@@ 13-32 (lines=20) @@
10
use Monolog\Logger;
11
use Sovereign\Lib\cURL;
12
13
class reapers
14
{
15
    public function run(Message $message, Discord $discord, WebSocket $webSocket, Logger $log, &$audioStreams, Channel $channel, cURL $curl)
16
    {
17
        $webSocket->joinVoiceChannel($channel)->then(function (VoiceClient $vc) use ($message, $discord, $webSocket, $log, &$audioStreams, $channel) {
18
            $guildID = $message->getChannelAttribute()->guild_id;
19
            // Add this audio stream to the array of audio streams
20
            $audioStreams[$guildID] = $vc;
21
            $vc->setFrameSize(40)->then(function () use ($vc, &$audioStreams, $guildID) {
22
                $vc->setBitrate(128000);
23
                $number = mt_rand(1, 23);
24
                $file = __DIR__ . "/../../../sounds/reapers/{$number}.mp3";
25
                $vc->playFile($file, 2)->done(function () use ($vc, &$audioStreams, $guildID) {
26
                    unset($audioStreams[$guildID]);
27
                    $vc->close();
28
                });
29
            });
30
        });
31
    }
32
}
33

src/Plugins/onVoice/warnings.php 1 location

@@ 13-32 (lines=20) @@
10
use Monolog\Logger;
11
use Sovereign\Lib\cURL;
12
13
class warnings
14
{
15
    public function run(Message $message, Discord $discord, WebSocket $webSocket, Logger $log, &$audioStreams, Channel $channel, cURL $curl)
16
    {
17
        $webSocket->joinVoiceChannel($channel)->then(function (VoiceClient $vc) use ($message, $discord, $webSocket, $log, &$audioStreams, $channel) {
18
            $guildID = $message->getChannelAttribute()->guild_id;
19
            // Add this audio stream to the array of audio streams
20
            $audioStreams[$guildID] = $vc;
21
            $vc->setFrameSize(40)->then(function () use ($vc, &$audioStreams, $guildID) {
22
                $vc->setBitrate(128000);
23
                $number = mt_rand(1, 6);
24
                $file = __DIR__ . "/../../../sounds/eve/{$number}.mp3";
25
                $vc->playFile($file, 2)->done(function () use ($vc, &$audioStreams, $guildID) {
26
                    unset($audioStreams[$guildID]);
27
                    $vc->close();
28
                });
29
            });
30
        });
31
    }
32
}
33