@@ -711,7 +711,7 @@ var InternalClient = (function () {
711711 // def moveMember
712712
713713 InternalClient . prototype . moveMember = function moveMember ( user , channel ) {
714- var _this19 = this ;
714+ var _this20 = this ;
715715
716716 user = this . resolver . resolveUser ( user ) ;
717717 return this . resolver . resolveChannel ( channel ) . then ( function ( channel ) {
@@ -721,7 +721,7 @@ var InternalClient = (function () {
721721 if ( channel . type !== "voice" ) {
722722 throw new Error ( "Can't moveMember into a non-voice channel" ) ;
723723 } else {
724- return _this19 . apiRequest ( "patch" , _Constants . Endpoints . SERVER_MEMBERS ( server . id ) + "/" + user . id , true , { channel_id : channel . id } ) . then ( function ( res ) {
724+ return _this20 . apiRequest ( "patch" , _Constants . Endpoints . SERVER_MEMBERS ( server . id ) + "/" + user . id , true , { channel_id : channel . id } ) . then ( function ( res ) {
725725 user . voiceChannel = channel ;
726726 return res ;
727727 } ) ;
@@ -732,15 +732,15 @@ var InternalClient = (function () {
732732 // def createRole
733733
734734 InternalClient . prototype . createRole = function createRole ( server , data ) {
735- var _this20 = this ;
735+ var _this21 = this ;
736736
737737 server = this . resolver . resolveServer ( server ) ;
738738
739739 return this . apiRequest ( "post" , _Constants . Endpoints . SERVER_ROLES ( server . id ) , true ) . then ( function ( res ) {
740- var role = server . roles . add ( new _StructuresRole2 [ "default" ] ( res , server , _this20 . client ) ) ;
740+ var role = server . roles . add ( new _StructuresRole2 [ "default" ] ( res , server , _this21 . client ) ) ;
741741
742742 if ( data ) {
743- return _this20 . updateRole ( role , data ) ;
743+ return _this21 . updateRole ( role , data ) ;
744744 }
745745 return role ;
746746 } ) ;
@@ -749,7 +749,7 @@ var InternalClient = (function () {
749749 // def updateRole
750750
751751 InternalClient . prototype . updateRole = function updateRole ( role , data ) {
752- var _this21 = this ;
752+ var _this22 = this ;
753753
754754 var server = this . resolver . resolveServer ( role . server ) ;
755755
@@ -785,7 +785,7 @@ var InternalClient = (function () {
785785 }
786786
787787 return this . apiRequest ( "patch" , _Constants . Endpoints . SERVER_ROLES ( server . id ) + "/" + role . id , true , newData ) . then ( function ( res ) {
788- return server . roles . update ( role , new _StructuresRole2 [ "default" ] ( res , server , _this21 . client ) ) ;
788+ return server . roles . update ( role , new _StructuresRole2 [ "default" ] ( res , server , _this22 . client ) ) ;
789789 } ) ;
790790 } ;
791791
@@ -797,37 +797,19 @@ var InternalClient = (function () {
797797
798798 //def addMemberToRole
799799
800- InternalClient . prototype . addMemberToRole = function addMemberToRole ( member , role ) {
801- member = this . resolver . resolveUser ( member ) ;
802-
803- if ( ! member || ! role ) {
804- return Promise . reject ( new Error ( "member/role not in server" ) ) ;
805- }
806-
807- if ( ! role . server . memberMap [ member . id ] ) {
808- return Promise . reject ( new Error ( "member not in server" ) ) ;
809- }
810-
811- var roleIDS = role . server . memberMap [ member . id ] . roles . map ( function ( r ) {
812- return r . id ;
813- } ) . concat ( role . id ) ;
814-
815- return this . apiRequest ( "patch" , _Constants . Endpoints . SERVER_MEMBERS ( role . server . id ) + "/" + member . id , true , {
816- roles : roleIDS
817- } ) ;
818- } ;
819-
820- //def addMemberToRole
821-
822- InternalClient . prototype . addMemberToRoles = function addMemberToRoles ( member , roles ) {
800+ InternalClient . prototype . addMemberToRole = function addMemberToRole ( member , roles ) {
823801 member = this . resolver . resolveUser ( member ) ;
824802
825803 if ( ! member ) {
826804 return Promise . reject ( new Error ( "member not in server" ) ) ;
827805 }
828806
829807 if ( ! Array . isArray ( roles ) || roles . length === 0 ) {
830- return Promise . reject ( new Error ( "invalid array of roles" ) ) ;
808+ if ( roles instanceof _StructuresRole2 [ "default" ] ) {
809+ roles = [ roles ] ;
810+ } else {
811+ return Promise . reject ( new Error ( "invalid array of roles" ) ) ;
812+ }
831813 }
832814
833815 if ( roles . some ( function ( role ) {
@@ -853,44 +835,19 @@ var InternalClient = (function () {
853835
854836 //def removeMemberFromRole
855837
856- InternalClient . prototype . removeMemberFromRole = function removeMemberFromRole ( member , role ) {
857- member = this . resolver . resolveUser ( member ) ;
858-
859- if ( ! member || ! role ) {
860- return Promise . reject ( new Error ( "member/role not in server" ) ) ;
861- }
862-
863- if ( ! role . server . memberMap [ member . id ] ) {
864- return Promise . reject ( new Error ( "member not in server" ) ) ;
865- }
866-
867- var roleIDS = role . server . memberMap [ member . id ] . roles . map ( function ( r ) {
868- return r . id ;
869- } ) ;
870-
871- for ( var item in roleIDS ) {
872- if ( roleIDS [ item ] === role . id ) {
873- roleIDS . splice ( item , 1 ) ;
874- break ;
875- }
876- }
877-
878- return this . apiRequest ( "patch" , _Constants . Endpoints . SERVER_MEMBERS ( role . server . id ) + "/" + member . id , true , {
879- roles : roleIDS
880- } ) ;
881- } ;
882-
883- //def removeMemberFromRoles
884-
885- InternalClient . prototype . removeMemberFromRoles = function removeMemberFromRoles ( member , roles ) {
838+ InternalClient . prototype . removeMemberFromRole = function removeMemberFromRole ( member , roles ) {
886839 member = this . resolver . resolveUser ( member ) ;
887840
888841 if ( ! member ) {
889842 return Promise . reject ( new Error ( "member not in server" ) ) ;
890843 }
891844
892845 if ( ! Array . isArray ( roles ) || roles . length === 0 ) {
893- return Promise . reject ( new Error ( "invalid array of roles" ) ) ;
846+ if ( roles instanceof _StructuresRole2 [ "default" ] ) {
847+ roles = [ roles ] ;
848+ } else {
849+ return Promise . reject ( new Error ( "invalid array of roles" ) ) ;
850+ }
894851 }
895852
896853 var roleIDS = roles [ 0 ] . server . memberMap [ member . id ] . roles . map ( function ( r ) {
@@ -930,7 +887,7 @@ var InternalClient = (function () {
930887 // def createInvite
931888
932889 InternalClient . prototype . createInvite = function createInvite ( chanServ , options ) {
933- var _this22 = this ;
890+ var _this23 = this ;
934891
935892 if ( chanServ instanceof _StructuresChannel2 [ "default" ] ) {
936893 // do something
@@ -963,7 +920,7 @@ var InternalClient = (function () {
963920 }
964921
965922 return this . apiRequest ( "post" , epoint , true , options ) . then ( function ( res ) {
966- return new _StructuresInvite2 [ "default" ] ( res , _this22 . channels . get ( "id" , res . channel . id ) , _this22 . client ) ;
923+ return new _StructuresInvite2 [ "default" ] ( res , _this23 . channels . get ( "id" , res . channel . id ) , _this23 . client ) ;
967924 } ) ;
968925 } ;
969926
@@ -980,42 +937,42 @@ var InternalClient = (function () {
980937 //def getInvite
981938
982939 InternalClient . prototype . getInvite = function getInvite ( invite ) {
983- var _this23 = this ;
940+ var _this24 = this ;
984941
985942 invite = this . resolver . resolveInviteID ( invite ) ;
986943 if ( ! invite ) {
987944 return Promise . reject ( new Error ( "Not a valid invite" ) ) ;
988945 }
989946
990947 return this . apiRequest ( "get" , _Constants . Endpoints . INVITE ( invite ) , true ) . then ( function ( res ) {
991- if ( ! _this23 . channels . has ( "id" , res . channel . id ) ) {
992- return new _StructuresInvite2 [ "default" ] ( res , null , _this23 . client ) ;
948+ if ( ! _this24 . channels . has ( "id" , res . channel . id ) ) {
949+ return new _StructuresInvite2 [ "default" ] ( res , null , _this24 . client ) ;
993950 }
994- return _this23 . apiRequest ( "post" , _Constants . Endpoints . CHANNEL_INVITES ( res . channel . id ) , true , { validate : invite } ) . then ( function ( res2 ) {
995- return new _StructuresInvite2 [ "default" ] ( res2 , _this23 . channels . get ( "id" , res . channel . id ) , _this23 . client ) ;
951+ return _this24 . apiRequest ( "post" , _Constants . Endpoints . CHANNEL_INVITES ( res . channel . id ) , true , { validate : invite } ) . then ( function ( res2 ) {
952+ return new _StructuresInvite2 [ "default" ] ( res2 , _this24 . channels . get ( "id" , res . channel . id ) , _this24 . client ) ;
996953 } ) ;
997954 } ) ;
998955 } ;
999956
1000957 //def getInvites
1001958
1002959 InternalClient . prototype . getInvites = function getInvites ( channel ) {
1003- var _this24 = this ;
960+ var _this25 = this ;
1004961
1005962 if ( ! ( channel instanceof _StructuresChannel2 [ "default" ] ) ) {
1006963 var server = this . resolver . resolveServer ( channel ) ;
1007964 if ( server ) {
1008965 return this . apiRequest ( "get" , _Constants . Endpoints . SERVER_INVITES ( server . id ) , true ) . then ( function ( res ) {
1009966 return res . map ( function ( data ) {
1010- return new _StructuresInvite2 [ "default" ] ( data , _this24 . channels . get ( "id" , data . channel . id ) , _this24 . client ) ;
967+ return new _StructuresInvite2 [ "default" ] ( data , _this25 . channels . get ( "id" , data . channel . id ) , _this25 . client ) ;
1011968 } ) ;
1012969 } ) ;
1013970 }
1014971 }
1015972 return this . resolver . resolveChannel ( channel ) . then ( function ( channel ) {
1016- return _this24 . apiRequest ( "get" , _Constants . Endpoints . CHANNEL_INVITES ( channel . id ) , true ) . then ( function ( res ) {
973+ return _this25 . apiRequest ( "get" , _Constants . Endpoints . CHANNEL_INVITES ( channel . id ) , true ) . then ( function ( res ) {
1017974 return res . map ( function ( data ) {
1018- return new _StructuresInvite2 [ "default" ] ( data , _this24 . channels . get ( "id" , data . channel . id ) , _this24 . client ) ;
975+ return new _StructuresInvite2 [ "default" ] ( data , _this25 . channels . get ( "id" , data . channel . id ) , _this25 . client ) ;
1019976 } ) ;
1020977 } ) ;
1021978 } ) ;
@@ -1024,7 +981,7 @@ var InternalClient = (function () {
1024981 //def overwritePermissions
1025982
1026983 InternalClient . prototype . overwritePermissions = function overwritePermissions ( channel , role , updated ) {
1027- var _this25 = this ;
984+ var _this26 = this ;
1028985
1029986 return this . resolver . resolveChannel ( channel ) . then ( function ( channel ) {
1030987 var user ;
@@ -1065,7 +1022,7 @@ var InternalClient = (function () {
10651022 }
10661023 }
10671024
1068- return _this25 . apiRequest ( "put" , _Constants . Endpoints . CHANNEL_PERMISSIONS ( channel . id ) + "/" + data . id , true , data ) ;
1025+ return _this26 . apiRequest ( "put" , _Constants . Endpoints . CHANNEL_PERMISSIONS ( channel . id ) + "/" + data . id , true , data ) ;
10691026 } ) ;
10701027 } ;
10711028
@@ -1101,49 +1058,49 @@ var InternalClient = (function () {
11011058 //def sendTyping
11021059
11031060 InternalClient . prototype . sendTyping = function sendTyping ( channel ) {
1104- var _this26 = this ;
1061+ var _this27 = this ;
11051062
11061063 return this . resolver . resolveChannel ( channel ) . then ( function ( channel ) {
1107- return _this26 . apiRequest ( "post" , _Constants . Endpoints . CHANNEL ( channel . id ) + "/typing" , true ) ;
1064+ return _this27 . apiRequest ( "post" , _Constants . Endpoints . CHANNEL ( channel . id ) + "/typing" , true ) ;
11081065 } ) ;
11091066 } ;
11101067
11111068 //def startTyping
11121069
11131070 InternalClient . prototype . startTyping = function startTyping ( channel ) {
1114- var _this27 = this ;
1071+ var _this28 = this ;
11151072
11161073 return this . resolver . resolveChannel ( channel ) . then ( function ( channel ) {
11171074
1118- if ( _this27 . intervals . typing [ channel . id ] ) {
1075+ if ( _this28 . intervals . typing [ channel . id ] ) {
11191076 // typing interval already exists, leave it alone
11201077 throw new Error ( "Already typing in that channel" ) ;
11211078 }
11221079
1123- _this27 . intervals . typing [ channel . id ] = setInterval ( function ( ) {
1124- return _this27 . sendTyping ( channel ) [ "catch" ] ( function ( error ) {
1125- return _this27 . emit ( "error" , error ) ;
1080+ _this28 . intervals . typing [ channel . id ] = setInterval ( function ( ) {
1081+ return _this28 . sendTyping ( channel ) [ "catch" ] ( function ( error ) {
1082+ return _this28 . emit ( "error" , error ) ;
11261083 } ) ;
11271084 } , 4000 ) ;
11281085
1129- return _this27 . sendTyping ( channel ) ;
1086+ return _this28 . sendTyping ( channel ) ;
11301087 } ) ;
11311088 } ;
11321089
11331090 //def stopTyping
11341091
11351092 InternalClient . prototype . stopTyping = function stopTyping ( channel ) {
1136- var _this28 = this ;
1093+ var _this29 = this ;
11371094
11381095 return this . resolver . resolveChannel ( channel ) . then ( function ( channel ) {
11391096
1140- if ( ! _this28 . intervals . typing [ channel . id ] ) {
1097+ if ( ! _this29 . intervals . typing [ channel . id ] ) {
11411098 // typing interval doesn"t exist
11421099 throw new Error ( "Not typing in that channel" ) ;
11431100 }
11441101
1145- clearInterval ( _this28 . intervals . typing [ channel . id ] ) ;
1146- _this28 . intervals . typing [ channel . id ] = false ;
1102+ clearInterval ( _this29 . intervals . typing [ channel . id ] ) ;
1103+ _this29 . intervals . typing [ channel . id ] = false ;
11471104 } ) ;
11481105 } ;
11491106
@@ -1177,12 +1134,12 @@ var InternalClient = (function () {
11771134 //def setChannelTopic
11781135
11791136 InternalClient . prototype . setChannelTopic = function setChannelTopic ( chann ) {
1180- var _this29 = this ;
1137+ var _this30 = this ;
11811138
11821139 var topic = arguments . length <= 1 || arguments [ 1 ] === undefined ? "" : arguments [ 1 ] ;
11831140
11841141 return this . resolver . resolveChannel ( chann ) . then ( function ( channel ) {
1185- return _this29 . apiRequest ( "patch" , _Constants . Endpoints . CHANNEL ( channel . id ) , true , {
1142+ return _this30 . apiRequest ( "patch" , _Constants . Endpoints . CHANNEL ( channel . id ) , true , {
11861143 name : channel . name ,
11871144 position : channel . position ,
11881145 topic : topic
@@ -1195,12 +1152,12 @@ var InternalClient = (function () {
11951152 //def setChannelName
11961153
11971154 InternalClient . prototype . setChannelName = function setChannelName ( chann ) {
1198- var _this30 = this ;
1155+ var _this31 = this ;
11991156
12001157 var name = arguments . length <= 1 || arguments [ 1 ] === undefined ? "discordjs_is_the_best" : arguments [ 1 ] ;
12011158
12021159 return this . resolver . resolveChannel ( chann ) . then ( function ( channel ) {
1203- return _this30 . apiRequest ( "patch" , _Constants . Endpoints . CHANNEL ( channel . id ) , true , {
1160+ return _this31 . apiRequest ( "patch" , _Constants . Endpoints . CHANNEL ( channel . id ) , true , {
12041161 name : name ,
12051162 position : channel . position ,
12061163 topic : channel . topic
@@ -1213,13 +1170,13 @@ var InternalClient = (function () {
12131170 //def setChannelNameAndTopic
12141171
12151172 InternalClient . prototype . setChannelNameAndTopic = function setChannelNameAndTopic ( chann ) {
1216- var _this31 = this ;
1173+ var _this32 = this ;
12171174
12181175 var name = arguments . length <= 1 || arguments [ 1 ] === undefined ? "discordjs_is_the_best" : arguments [ 1 ] ;
12191176 var topic = arguments . length <= 2 || arguments [ 2 ] === undefined ? "" : arguments [ 2 ] ;
12201177
12211178 return this . resolver . resolveChannel ( chann ) . then ( function ( channel ) {
1222- return _this31 . apiRequest ( "patch" , _Constants . Endpoints . CHANNEL ( channel . id ) , true , {
1179+ return _this32 . apiRequest ( "patch" , _Constants . Endpoints . CHANNEL ( channel . id ) , true , {
12231180 name : name ,
12241181 position : channel . position ,
12251182 topic : topic
@@ -1233,12 +1190,12 @@ var InternalClient = (function () {
12331190 //def setTopic
12341191
12351192 InternalClient . prototype . setChannelPosition = function setChannelPosition ( chann ) {
1236- var _this32 = this ;
1193+ var _this33 = this ;
12371194
12381195 var position = arguments . length <= 1 || arguments [ 1 ] === undefined ? 0 : arguments [ 1 ] ;
12391196
12401197 return this . resolver . resolveChannel ( chann ) . then ( function ( channel ) {
1241- return _this32 . apiRequest ( "patch" , _Constants . Endpoints . CHANNEL ( channel . id ) , true , {
1198+ return _this33 . apiRequest ( "patch" , _Constants . Endpoints . CHANNEL ( channel . id ) , true , {
12421199 name : channel . name ,
12431200 position : position ,
12441201 topic : channel . topic
0 commit comments