Skip to content

Commit

Permalink
Update | Beta 4.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gncdev committed Aug 10, 2020
1 parent 32ace70 commit f61cebf
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ class Ourted extends Bot

$ids = "";
// Count Messages
foreach (json_decode($this->channel->getMessages($channel)) as $key => $item) {
foreach ($this->channel->getMessages($channel) as $key => $item) {
if($key == 99){
return;
}
count(json_decode($this->channel->getMessages($channel))) -1 == $key?
count($this->channel->getMessages($channel)) -1 == $key?
$ids .= "\"$item->id\"" : $ids.= "\"$item->id\",";
}
// Delete Messages
Expand Down
6 changes: 3 additions & 3 deletions example/Ourted.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function setBot()
/* Embed Start */
$embed_array = array();
$embed_string = "";
foreach (json_decode($this->guild->get_guilds_properties()) as $key => $server) {
foreach ($this->guild->get_guilds_properties() as $key => $server) {
$embed_array[] = array("name" => "Server of {$key}.", "value" => $server->name);
$embed_string .= " Server of {$key}: {$server->name} ";
}
Expand All @@ -72,9 +72,9 @@ public function setBot()
/* Bulk Delete Start */
$ids = "";
// Count Messages
foreach (json_decode($this->channel->getMessages($channel)) as $key => $item) {
foreach ($this->channel->getMessages($channel) as $key => $item) {
if($key == 99){
return;
break;
}
count(json_decode($this->channel->getMessages($channel))) -1 == $key?
$ids .= "\"$item->id\"" : $ids.= "\"$item->id\",";
Expand Down
12 changes: 6 additions & 6 deletions src/Interfaces/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,30 @@ public function deleteMessage($message)
/**
* Deleting Message
*
* @return bool|string
* @return bool|array
* @var string $message
* @var \Ourted\Model\Channel\Channel $channel
*/

public function deleteBulkMessage($message, $channel)
{
return $this->bot->api->init_curl_with_header(
return json_decode($this->bot->api->init_curl_with_header(
"channels/{$channel->id}/messages/bulk-delete",
"{\"messages\":{$message}}", "POST");
"{\"messages\":{$message}}", "POST"));
}

/**
* Getting Messages in Selected Channel
*
* @return bool|string
* @return bool|array
* @var \Ourted\Model\Channel\Channel $channel Channel Instance
*/

public function getMessages($channel)
{
return $this->bot->api->init_curl_with_header(
return json_decode($this->bot->api->init_curl_with_header(
"channels/{$channel->id}/messages",
"", "GET");
"", "GET"));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Interfaces/Guild.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ public function __construct($bot)
/**
* Get guilds
*
* @return bool|string
* @return bool|array
*/

public function get_guilds_properties()
{
return $this->bot->api->init_curl_with_header(
return json_decode($this->bot->api->init_curl_with_header(
"users/@me/guilds",
"", "GET");
"", "GET"));
}

}
13 changes: 13 additions & 0 deletions src/Model/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ abstract class Command
*/
protected $bot;

/**
* Current bot instance
* @var stdClass $json
*/
protected $json;

/**
* Curernt loop instance
* @var EventLoop\
Expand All @@ -30,12 +36,19 @@ abstract class Command
public function __construct($bot, $command_name)
{
$bot->addDispatch('MESSAGE_CREATE', $command_name, function ($json) use ($command_name, $bot) {
$this->json = $json->d;
if (str_starts_with($json->d->content, $bot->prefix . $command_name)) {
$this->execute($json->d, $bot);
}
});
}

protected function getArgs(){
$result = explode(" ", $this->json->content);
unset($result[0]);
return $result;
}

/**
* Execute
*
Expand Down
2 changes: 1 addition & 1 deletion src/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class State
/**
* @var bool
*/
public $send_log = false;
public $send_log = true;

/**
* Discord API operations to class relationships
Expand Down

0 comments on commit f61cebf

Please sign in to comment.