Skip to content

Commit 28afc64

Browse files
committed
Update | Beta 5.1.1
1 parent 1c76f74 commit 28afc64

File tree

2 files changed

+24
-28
lines changed

2 files changed

+24
-28
lines changed

example/Ourted.php

+10-19
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Ourted extends Bot
1111

1212
public function __construct()
1313
{
14-
$dotenv = Dotenv::createImmutable(__DIR__ . '/../');
14+
$dotenv = Dotenv::createImmutable(__DIR__);
1515
$dotenv->load();
1616
$this->token = $_ENV['BOT_TOKEN'];
1717
parent::__construct($this->token, "!");
@@ -42,33 +42,22 @@ public function setBot()
4242
// Change Bot Username
4343
$settings->change_bot_username("test_bot");
4444

45-
/* Embed Start */
46-
$embed_array = array();
47-
$embed_string = "";
48-
foreach ($this->guild->get_guilds_properties() as $key => $server) {
49-
$embed_array[] = array("name" => "Server of {$key}.", "value" => $server->name);
50-
$embed_string .= " Server of {$key}: {$server->name} ";
51-
}
5245

5346

54-
// Without Embed
55-
$this->channel->sendMessage("Family: " . $embed_string, $channel);
47+
/* Embed Start */
5648

5749

58-
// With Single Array
59-
$embed = $this->createEmbed("Family", $channel, "Family");
60-
$embed->add_field($embed_array);
50+
$embed = $this->createEmbed("TITLE", $channel, "DESCIPTION");
51+
$embed->add_field("Field 1", "Field 1 Value");
52+
$embed->add_field("Field 2", "Field 2 Value");
6153
$embed->send_embed();
6254

55+
/* Embed End */
6356

64-
// With Multiple Array
65-
$embed = $this->createEmbed("Family", $channel, "Family");
66-
$embed->add_field(array("name" => "Field 1", "value" => "Field 1 Value"), array("name" => "Field 2", "value" => "Field 2 Value"));
67-
$embed->send_embed();
6857

69-
/* Embed End */
7058

7159
/* Bulk Delete Start */
60+
7261
$ids = "";
7362
// Count Messages
7463
foreach ($this->channel->getMessages($channel) as $key => $item) {
@@ -78,9 +67,11 @@ public function setBot()
7867
count(json_decode($this->channel->getMessages($channel))) -1 == $key?
7968
$ids .= "\"$item->id\"" : $ids.= "\"$item->id\",";
8069
}
81-
// Delete Messages
70+
// Delete Bulk Message
8271
$this->channel->deleteBulkMessage("[{$ids}]", $channel);
8372

73+
/* Bulk Delete End */
74+
8475
// Get Role
8576
echo $this->guild->getRole($this->guild->getGuild(742361616728719373), 742404691979272203)->name;
8677
// Result: Test

src/Model/Message/Embed.php

+14-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class Embed
1313
protected $token;
1414
private $embed = [];
1515
private $fields = [];
16-
private $fields_arr = [];
1716

1817

1918
/**
@@ -33,18 +32,14 @@ public function __construct($title, $bot, $channel, $description = "")
3332

3433

3534
/**
36-
* @var array $field Fields In Array
35+
* @var string $name Fields In Array
36+
* @var string $value Fields In Array
3737
*
3838
*/
3939

40-
public function add_field(array ...$field)
40+
public function add_field(string $name, string $value)
4141
{
42-
if(isset($field[0][0])){
43-
$this->fields[] = $field;
44-
}else{
45-
$this->fields_arr[] = $field;
46-
}
47-
42+
$this->fields[] = array("name" => "{$name}", "value" => "{$value}");
4843
}
4944

5045
/**
@@ -55,6 +50,15 @@ public function add_field(array ...$field)
5550
private function get_fields()
5651
{
5752
$data = "";
53+
foreach ($this->fields as $key => $item){
54+
$count_field = count($this->fields);
55+
$data .= $count_field -1 == $key ?
56+
// If
57+
"{\"name\":\"{$item["name"]}\",\"value\":\"{$item["value"]}\"}" :
58+
// If Not
59+
"{\"name\":\"{$item["name"]}\",\"value\":\"{$item["value"]}\"},";
60+
}
61+
/*
5862
if (!isset($this->fields[0][0][0])){
5963
if(!isset($this->fields_arr[0])){
6064
return "";
@@ -77,6 +81,7 @@ private function get_fields()
7781
"{\"name\":\"{$item["name"]}\",\"value\":\"{$item["value"]}\"},";
7882
}
7983
}
84+
*/
8085
return $data;
8186
}
8287

0 commit comments

Comments
 (0)