44
55use Ourted \Bot ;
66use Ourted \Model \Channel \Message ;
7+ use Ourted \Model \Channel \Overwrite ;
78
8- class Channel{
9+ class Channel
10+ {
911
1012 /** @var Bot */
1113 private $ bot ;
@@ -15,7 +17,8 @@ public function __construct($bot)
1517 $ this ->bot = $ bot ;
1618 }
1719
18- public function getChannel ($ channel_id ){
20+ public function getChannel ($ channel_id )
21+ {
1922 return new \Ourted \Model \Channel \Channel ($ this ->bot , $ channel_id );
2023 }
2124
@@ -27,7 +30,8 @@ public function getChannel($channel_id){
2730 * @var \Ourted\Model\Channel\Channel $channel
2831 */
2932
30- public function sendMessage ($ message , $ channel ){
33+ public function sendMessage ($ message , $ channel )
34+ {
3135 $ this ->bot ->api ->send (
3236 "channels/ {$ channel ->id }/messages " ,
3337 "{ \"content \": \"{$ message }\"} " );
@@ -95,8 +99,27 @@ public function getMessage($channel, $message_id)
9599 * @param $channel \Ourted\Model\Channel\Channel
96100 * @return mixed
97101 */
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 " ));
100105 }
101106
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+ }
102125}
0 commit comments