Skip to content

Commit 6f8b34f

Browse files
committed
Update | Beta 5.0.7
1 parent e2d7d58 commit 6f8b34f

File tree

4 files changed

+18
-24
lines changed

4 files changed

+18
-24
lines changed

example/Ourted.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Dotenv\Dotenv;
66
use Ourted\Bot;
7-
use Ourted\Model\Message\Embed;
87

98
class Ourted extends Bot
109
{
@@ -57,13 +56,13 @@ public function setBot()
5756

5857

5958
// With Single Array
60-
$embed = new Embed("Family", parent::getBot(), "701838704095920198", "Family");
59+
$embed = $this->createEmbed("Family", $channel, "Family");
6160
$embed->add_field($embed_array);
6261
$embed->send_embed();
6362

6463

6564
// With Multiple Array
66-
$embed = new Embed("Family", parent::getBot(), "701838704095920198", "Family");
65+
$embed = $this->createEmbed("Family", $channel, "Family");
6766
$embed->add_field(array("name" => "Field 1", "value" => "Field 1 Value"), array("name" => "Field 2", "value" => "Field 2 Value"));
6867
$embed->send_embed();
6968

src/Bot.php

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Ourted\Interfaces\Channel;
88
use Ourted\Interfaces\Guild;
99
use Ourted\Interfaces\User;
10+
use Ourted\Model\Message\Embed;
1011
use Ourted\Utils\API;
1112
use Ratchet\Client\Connector;
1213
use Ratchet\Client\WebSocket;
@@ -128,6 +129,15 @@ public function addCommand($command_name, $function)
128129
$function($this, $command_name);
129130
}
130131

132+
/**
133+
* @param $title
134+
* @param \Ourted\Model\Channel\Channel $channel
135+
* @param string $description
136+
*/
137+
public function createEmbed($title, $channel, $description = ""){
138+
return new Embed($title, $this, $channel, $description);
139+
}
140+
131141
/**
132142
* Set Bot
133143
*

src/Model/Command/Command.php

+1-16
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ public function __construct($bot, $command_name)
3939
$bot->addDispatch('MESSAGE_CREATE', function ($json) use ($command_name, $bot) {
4040
$this->json = $json->d;
4141
if (str_starts_with($json->d->content, $bot->prefix . $command_name)) {
42-
$res = $this->execute($this->bot->channel->getMessage($bot->channel->getChannel($json->d->channel_id), intval($json->d->id)), $bot);
43-
if(isset(json_decode($res)->message)){
44-
$this->onFail(json_decode($res)->message, $this->bot);
45-
}
42+
$this->execute($this->bot->channel->getMessage($bot->channel->getChannel($json->d->channel_id), intval($json->d->id)), $bot);
4643
}
4744
});
4845
}
@@ -61,16 +58,4 @@ protected function getArgs(){
6158
*
6259
*/
6360
public abstract function execute($message, $bot);
64-
65-
/**
66-
* On Fail
67-
*
68-
* @param string $fail
69-
* @param Bot $bot
70-
*
71-
*/
72-
public function onFail($fail, $bot){
73-
74-
}
75-
7661
}

src/Model/Message/Embed.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Ourted\Model\Message;
44

55
use Ourted\Bot;
6+
use Ourted\Model\Channel\Channel;
67

78
class Embed
89
{
@@ -16,22 +17,21 @@ class Embed
1617

1718

1819
/**
19-
*
20-
*
2120
* @param $title
2221
* @param Bot $bot
23-
* @param $channel_id
22+
* @param Channel $channel
2423
* @param string $description
2524
*/
26-
public function __construct($title, $bot, $channel_id, $description = "")
25+
public function __construct($title, $bot, $channel, $description = "")
2726
{
2827
$this->embed['title'] = $title;
2928
$this->embed['description'] = $description;
30-
$this->embed['channel_id'] = $channel_id;
29+
$this->embed['channel_id'] = $channel->id;
3130
$this->bot = $bot->getBot();
3231
$this->token = $bot->getToken();
3332
}
3433

34+
3535
/**
3636
* @var array $field Fields In Array
3737
*

0 commit comments

Comments
 (0)