-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* unfinished music commands * commands: music: fix conflicts * commands: Play: add loop * commands: Play: fix sendMessage on null * commands: Play: fix Uncaught Error: Cannot use object of type hiro\parts\VoiceSettings as array * parts: Update VoiceSettings * commands: Loop: added * commands: Play: stop using $msg variable * Update Loop.php * commands: Play: Undefined variable $textChannel * commands: Play: fix Call to undefined method Discord\Parts\Channel\Message::sendMessage() * commands: music: made music commands better * parts: VoiceSettings: fix setVoiceClient() function * commands: Play: fix playMusic() usage * commands: Play: fix sth * commands: Play: fix syntax * commands: Play: fix syntax error, unexpected token }, expecting ; * commands: Play: fix Object of class hiro\parts\VoiceFile could not be converted to string * commands: Play: ported 'textChannel' to 'text_channel' * commands: Play: fix 'Undefined variable $author_id' * commands: Play: delete message after play sound * commands: Play: send information after add queue * commands: Play: fix queue * commands: Play: tried to fix bot is always trying to play * commands: Play: fix 'Undefined variable $settings' * commands: Play: fix bot is not playing next song * parts: VoiceSettings: debugging * commands: Play: tried to fix queue system * commands: Play: hmm * parts: VoiceSettings: close debug * commands: Skip: added * commands: Skip: add exactly skip song * commands: Skip: skip the song if loop is enabled too * commands: Play: tried to fix double play * commands: Play: shift queue after song end not while playing song
- Loading branch information
1 parent
b260496
commit 8dadd64
Showing
9 changed files
with
406 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2023 bariscodefx | ||
* | ||
* This file is part of project Hiro 016 Discord Bot. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace hiro\commands; | ||
|
||
use Discord\Voice\VoiceClient; | ||
use React\ChildProcess\Process; | ||
use Discord\Builders\MessageBuilder; | ||
|
||
class Loop extends Command | ||
{ | ||
public function configure(): void | ||
{ | ||
$this->command = "loop"; | ||
$this->description = "Enables or disables looping in music."; | ||
$this->aliases = []; | ||
$this->category = "music"; | ||
} | ||
|
||
public function handle($msg, $args): void | ||
{ | ||
global $voiceSettings; | ||
$channel = $msg->member->getVoiceChannel(); | ||
$voiceClient = $this->discord->getVoiceClient($msg->guild_id); | ||
|
||
if (!$channel) { | ||
$msg->channel->sendMessage("You must be in a voice channel."); | ||
return; | ||
} | ||
|
||
if (!$voiceClient) { | ||
$msg->reply("Use the join command first.\n"); | ||
return; | ||
} | ||
|
||
if ($voiceClient && $channel->id !== $voiceClient->getChannel()->id) { | ||
$msg->reply("You must be in the same channel with me."); | ||
return; | ||
} | ||
|
||
$settings = @$voiceSettings[$msg->channel->guild_id]; | ||
|
||
if (!$settings) | ||
{ | ||
$msg->reply("Voice options couldn't found."); | ||
return; | ||
} | ||
|
||
if ($settings->getLoopEnabled()) | ||
{ | ||
$settings->setLoopEnabled(false); | ||
$msg->reply("Loop is **disabled** now."); | ||
} else { | ||
$settings->setLoopEnabled(true); | ||
$msg->reply("Loop is **enabled** now."); | ||
} | ||
} | ||
} |
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,77 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2023 bariscodefx | ||
* | ||
* This file part of project Hiro 016 Discord Bot. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace hiro\commands; | ||
|
||
use Discord\Voice\VoiceClient; | ||
|
||
class Skip extends Command | ||
{ | ||
/** | ||
* configure | ||
* | ||
* @return void | ||
*/ | ||
public function configure(): void | ||
{ | ||
$this->command = "skip"; | ||
$this->description = "Skips the current song."; | ||
$this->aliases = []; | ||
$this->category = "music"; | ||
} | ||
|
||
/** | ||
* handle | ||
* | ||
* @param [type] $msg | ||
* @param [type] $args | ||
* @return void | ||
*/ | ||
public function handle($msg, $args): void | ||
{ | ||
global $voiceSettings; | ||
$channel = $msg->member->getVoiceChannel(); | ||
|
||
$voiceClient = $this->discord->getVoiceClient($msg->channel->guild_id); | ||
|
||
if ($voiceClient && $channel->id !== $voiceClient->getChannel()->id) { | ||
$msg->channel->sendMessage("You must be in same channel with me."); | ||
return; | ||
} | ||
|
||
$settings = @$voiceSettings[$msg->guild_id]; | ||
if(!$settings) | ||
{ | ||
$msg->channel->sendMessage("Voice settings couldn't found."); | ||
return; | ||
} | ||
|
||
try { | ||
$voiceClient->stop(); | ||
if($cmd = $this->loader->getCmd("play")) | ||
{ | ||
$settings->nextSong(); | ||
$cmd->playMusic($msg->channel, $settings); | ||
} | ||
} catch (\Throwable $e) { | ||
$msg->reply($e->getMessage()); | ||
} | ||
} | ||
} |
Oops, something went wrong.