4
4
5
5
use Ourted \Bot ;
6
6
use Ourted \Model \Channel \Message ;
7
+ use Ourted \Model \Channel \Overwrite ;
7
8
8
- class Channel{
9
+ class Channel
10
+ {
9
11
10
12
/** @var Bot */
11
13
private $ bot ;
@@ -15,7 +17,8 @@ public function __construct($bot)
15
17
$ this ->bot = $ bot ;
16
18
}
17
19
18
- public function getChannel ($ channel_id ){
20
+ public function getChannel ($ channel_id )
21
+ {
19
22
return new \Ourted \Model \Channel \Channel ($ this ->bot , $ channel_id );
20
23
}
21
24
@@ -27,7 +30,8 @@ public function getChannel($channel_id){
27
30
* @var \Ourted\Model\Channel\Channel $channel
28
31
*/
29
32
30
- public function sendMessage ($ message , $ channel ){
33
+ public function sendMessage ($ message , $ channel )
34
+ {
31
35
$ this ->bot ->api ->send (
32
36
"channels/ {$ channel ->id }/messages " ,
33
37
"{ \"content \": \"{$ message }\"} " );
@@ -95,8 +99,27 @@ public function getMessage($channel, $message_id)
95
99
* @param $channel \Ourted\Model\Channel\Channel
96
100
* @return mixed
97
101
*/
98
- public function deleteChannel ($ channel ){
99
- return json_decode ($ this ->bot ->api ->send ("channels/ {$ channel ->id }" ,"" , "DELETE " ));
102
+ public function deleteChannel ($ channel )
103
+ {
104
+ return json_decode ($ this ->bot ->api ->send ("channels/ {$ channel ->id }" , "" , "DELETE " ));
100
105
}
101
106
107
+ /**
108
+ * @param array $overwrites
109
+ * @return array
110
+ */
111
+ public function createOverwrite (array ...$ overwrites )
112
+ {
113
+ $ r = array ();
114
+ array_keys ($ overwrites );
115
+ foreach ($ overwrites as $ item ) {
116
+ $ id = $ item [0 ];
117
+ $ type = $ item [1 ];
118
+ $ allow = $ item [2 ];
119
+ $ deny = $ item [3 ];
120
+ $ o = new Overwrite ($ id , $ type , $ allow , $ deny );
121
+ $ r [] = $ o ->create_object ();
122
+ }
123
+ return $ r ;
124
+ }
102
125
}
0 commit comments