idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
53,400 | function clone ( string $ name = null , bool $ withPermissions = true , bool $ withTopic = true , string $ reason = '' ) { $ data = array ( 'name' => ( ! empty ( $ name ) ? ( ( string ) $ name ) : $ this -> name ) , 'type' => \ CharlotteDunois \ Yasmin \ Models \ ChannelStorage :: getTypeForChannel ( $ this ) ) ; if ( ... | Clones a guild channel . Resolves with an instance of GuildChannelInterface . |
53,401 | function fetchInvites ( ) { return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) { $ this -> client -> apimanager ( ) -> endpoints -> channel -> getChannelInvites ( $ this -> id ) -> done ( function ( $ data ) use ( $ resolve ) { $ collection = new \ CharlotteDunois \ Collect \... | Fetches all invites of this channel . Resolves with a Collection of Invite instances mapped by their code . |
53,402 | function permissionsFor ( $ member ) { $ member = $ this -> guild -> members -> resolve ( $ member ) ; if ( $ member -> id === $ this -> guild -> ownerID ) { return ( new \ CharlotteDunois \ Yasmin \ Models \ Permissions ( \ CharlotteDunois \ Yasmin \ Models \ Permissions :: ALL ) ) ; } $ permissions = $ member -> perm... | Returns the permissions for the given member . |
53,403 | function overwritesFor ( $ member ) { $ member = $ this -> guild -> members -> resolve ( $ member ) ; $ everyoneOverwrites = null ; $ memberOverwrites = null ; $ rolesOverwrites = array ( ) ; foreach ( $ this -> permissionOverwrites as $ overwrite ) { if ( $ overwrite -> id === $ this -> guild -> id ) { $ everyoneOverw... | Returns the permissions overwrites for the given member as an associative array . |
53,404 | function overwritePermissions ( $ memberOrRole , $ allow , $ deny = 0 , string $ reason = '' ) { [ $ memberOrRole , $ options ] = $ this -> validateOverwritePermissions ( $ memberOrRole , $ allow , $ deny ) ; return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) use ( $ memberOr... | Overwrites the permissions for a member or role in this channel . Resolves with an instance of PermissionOverwrite . |
53,405 | protected function validateOverwritePermissions ( $ memberOrRole , $ allow , $ deny = 0 ) { $ options = array ( ) ; if ( $ memberOrRole instanceof \ CharlotteDunois \ Yasmin \ Models \ GuildMember ) { $ memberOrRole = $ memberOrRole -> id ; $ options [ 'type' ] = 'member' ; } elseif ( $ memberOrRole instanceof \ Charlo... | Validates the given overwritePermissions arguments . |
53,406 | function getChildren ( ) { return $ this -> guild -> channels -> filter ( function ( $ channel ) { return ( $ channel -> parentID === $ this -> id ) ; } ) ; } | Returns all channels which are childrens of this category . |
53,407 | function delete ( string $ reason = '' ) { return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) use ( $ reason ) { $ method = 'deleteWebhook' ; $ args = array ( $ this -> id , $ reason ) ; if ( ! empty ( $ this -> token ) ) { $ method = 'deleteWebhookToken' ; $ args = array ( $... | Deletes the webhook . |
53,408 | protected function executeWebhook ( array $ opts , array $ files ) { return $ this -> client -> apimanager ( ) -> endpoints -> webhook -> executeWebhook ( $ this -> id , $ this -> token , $ opts , $ files , array ( 'wait' => true ) ) -> then ( function ( $ data ) { $ channel = $ this -> client -> channels -> get ( $ th... | Executes the webhook effectively . Resolves with an instance of Message . |
53,409 | function resolve ( $ channel ) { if ( $ channel instanceof \ CharlotteDunois \ Yasmin \ Interfaces \ ChannelInterface ) { return $ channel ; } if ( \ is_int ( $ channel ) ) { $ channel = ( string ) $ channel ; } if ( \ is_string ( $ channel ) && parent :: has ( $ channel ) ) { return parent :: get ( $ channel ) ; } thr... | Resolves given data to a channel . |
53,410 | static function getTypeForChannel ( \ CharlotteDunois \ Yasmin \ Interfaces \ ChannelInterface $ channel ) { if ( $ channel instanceof \ CharlotteDunois \ Yasmin \ Interfaces \ GroupDMChannelInterface ) { return self :: CHANNEL_TYPES [ 'group' ] ; } elseif ( $ channel instanceof \ CharlotteDunois \ Yasmin \ Interfaces ... | Get the type for the channel . |
53,411 | static function resolveColor ( $ color ) { if ( \ is_int ( $ color ) ) { return $ color ; } if ( ! \ is_array ( $ color ) ) { return \ hexdec ( ( ( string ) $ color ) ) ; } if ( \ count ( $ color ) < 1 ) { throw new \ InvalidArgumentException ( 'Color "' . \ var_export ( $ color , true ) . '" is not resolvable' ) ; } r... | Resolves a color to an integer . |
53,412 | static function makeDateTime ( int $ timestamp ) { $ zone = new \ DateTimeZone ( \ date_default_timezone_get ( ) ) ; return ( new \ DateTime ( '@' . $ timestamp ) ) -> setTimezone ( $ zone ) ; } | Makes a DateTime instance from an UNIX timestamp and applies the default timezone . |
53,413 | static function makeBase64URI ( string $ data ) { $ img = \ getimagesizefromstring ( $ data ) ; if ( ! $ img ) { throw new \ InvalidArgumentException ( 'Bad input data' ) ; } return 'data:' . $ img [ 'mime' ] . ';base64,' . \ base64_encode ( $ data ) ; } | Turns input into a base64 - encoded data URI . |
53,414 | static function typecastVariable ( $ variable , string $ type ) { if ( $ variable === null ) { return null ; } switch ( $ type ) { case 'array' : $ variable = ( array ) $ variable ; break ; case 'bool' : $ variable = ( bool ) $ variable ; break ; case 'float' : $ variable = ( float ) $ variable ; break ; case 'int' : $... | Typecasts the variable to the type if not null . |
53,415 | static function applyOptions ( array $ input , array $ options ) { $ data = array ( ) ; foreach ( $ input as $ key => $ val ) { if ( ! isset ( $ options [ $ key ] ) ) { continue ; } if ( \ is_array ( $ options [ $ key ] ) ) { if ( ! empty ( $ options [ $ key ] [ 'parse' ] ) ) { $ call = $ options [ $ key ] [ 'parse' ] ... | Converts the input to the specified options . |
53,416 | function fetchMessage ( string $ id ) { return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) use ( $ id ) { $ this -> client -> apimanager ( ) -> endpoints -> channel -> getChannelMessage ( $ this -> id , $ id ) -> done ( function ( $ data ) use ( $ resolve ) { $ message = $ th... | Fetches a specific message using the ID . Resolves with an instance of Message . |
53,417 | function fetchMessages ( array $ options = array ( ) ) { return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) use ( $ options ) { $ this -> client -> apimanager ( ) -> endpoints -> channel -> getChannelMessages ( $ this -> id , $ options ) -> done ( function ( $ data ) use ( $ ... | Fetches messages of this channel . Resolves with a Collection of Message instances mapped by their ID . |
53,418 | function getLastMessage ( ) { if ( ! empty ( $ this -> lastMessageID ) && $ this -> messages -> has ( $ this -> lastMessageID ) ) { return $ this -> messages -> get ( $ this -> lastMessageID ) ; } return null ; } | Gets the last message in this channel if cached or null . |
53,419 | function startTyping ( ) { if ( $ this -> typingTriggered [ 'count' ] === 0 ) { $ fn = function ( ) { $ this -> client -> apimanager ( ) -> endpoints -> channel -> triggerChannelTyping ( $ this -> id ) -> done ( function ( ) { $ this -> _updateTyping ( $ this -> client -> user , \ time ( ) ) ; } , function ( ) { $ this... | Starts sending the typing indicator in this channel . Counts up a triggered typing counter . |
53,420 | function stopTyping ( bool $ force = false ) { if ( $ this -> typingTriggered [ 'count' ] === 0 ) { return ; } $ this -> typingTriggered [ 'count' ] -- ; if ( $ force ) { $ this -> typingTriggered [ 'count' ] = 0 ; } if ( $ this -> typingTriggered [ 'count' ] === 0 ) { if ( $ this -> typingTriggered [ 'timer' ] ) { $ t... | Stops sending the typing indicator in this channel . Counts down a triggered typing counter . |
53,421 | function isTyping ( \ CharlotteDunois \ Yasmin \ Models \ User $ user ) { return $ this -> typings -> has ( $ user -> id ) ; } | Determines whether the given user is typing in this channel or not . |
53,422 | function isTypingSince ( \ CharlotteDunois \ Yasmin \ Models \ User $ user ) { if ( ! $ this -> isTyping ( $ user ) ) { return - 1 ; } return ( \ time ( ) - $ this -> typings -> get ( $ user -> id ) [ 'timestamp' ] ) ; } | Determines whether how long the given user has been typing in this channel . Returns - 1 if the user is not typing . |
53,423 | function decompress ( string $ data ) : string { if ( ! $ this -> context ) { throw new \ CharlotteDunois \ Yasmin \ WebSocket \ DiscordGatewayException ( 'No inflate context initialized' ) ; } $ uncompressed = \ inflate_add ( $ this -> context , $ data ) ; if ( $ uncompressed === false ) { throw new \ CharlotteDunois ... | Decompresses data . |
53,424 | function resolve ( $ user ) { if ( $ user instanceof \ CharlotteDunois \ Yasmin \ Models \ User ) { return $ user ; } if ( $ user instanceof \ CharlotteDunois \ Yasmin \ Models \ GuildMember ) { return $ user -> user ; } if ( \ is_int ( $ user ) ) { $ user = ( string ) $ user ; } if ( \ is_string ( $ user ) && parent :... | Resolves given data to an user . |
53,425 | function setAuthor ( $ name , string $ iconurl = '' , string $ url = '' ) { $ name = ( string ) $ name ; if ( \ mb_strlen ( $ name ) > 256 ) { throw new \ InvalidArgumentException ( 'Author name can not be longer than 256 characters.' ) ; } $ this -> author = array ( 'name' => $ name , 'icon_url' => $ iconurl , 'url' =... | Set the author of this embed . |
53,426 | function setColor ( $ color ) { $ this -> color = \ CharlotteDunois \ Yasmin \ Utils \ DataHelpers :: resolveColor ( $ color ) ; return $ this ; } | Set the color of this embed . |
53,427 | function setDescription ( $ description ) { $ description = ( string ) $ description ; if ( \ mb_strlen ( $ description ) > 2048 ) { throw new \ InvalidArgumentException ( 'Embed description can not be longer than 2048 characters' ) ; } $ this -> description = $ description ; return $ this ; } | Set the description of this embed . |
53,428 | function setFooter ( $ text , string $ iconurl = '' ) { $ text = ( string ) $ text ; if ( \ mb_strlen ( $ text ) > 2048 ) { throw new \ InvalidArgumentException ( 'Footer text can not be longer than 2048 characters.' ) ; } $ this -> footer = array ( 'text' => $ text , 'icon_url' => $ iconurl ) ; return $ this ; } | Set the footer of this embed . |
53,429 | function setTimestamp ( ? int $ timestamp = null ) { $ this -> timestamp = ( new \ DateTime ( ( $ timestamp !== null ? '@' . $ timestamp : 'now' ) ) ) -> format ( 'c' ) ; return $ this ; } | Set the timestamp of this embed . |
53,430 | function setTitle ( string $ title ) { if ( \ mb_strlen ( $ title ) > 256 ) { throw new \ InvalidArgumentException ( 'Embed title can not be longer than 256 characters' ) ; } $ this -> title = $ title ; return $ this ; } | Set the title of this embed . |
53,431 | function addField ( $ title , $ value , bool $ inline = false ) { if ( \ count ( $ this -> fields ) >= 25 ) { throw new \ RangeException ( 'Embeds can not have more than 25 fields' ) ; } $ title = ( string ) $ title ; $ value = ( string ) $ value ; if ( \ mb_strlen ( $ title ) > 256 ) { throw new \ InvalidArgumentExcep... | Adds a field to this embed . |
53,432 | function fetchUsers ( int $ limit = 100 , string $ before = '' , string $ after = '' ) { return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) use ( $ limit , $ before , $ after ) { $ query = array ( 'limit' => $ limit ) ; if ( ! empty ( $ before ) ) { $ query [ 'before' ] = $ b... | Fetches all the users that gave this reaction . Resolves with a Collection of User instances mapped by their IDs . |
53,433 | function resolve ( $ role ) { if ( $ role instanceof \ CharlotteDunois \ Yasmin \ Models \ Role ) { return $ role ; } if ( \ is_int ( $ role ) ) { $ role = ( string ) $ role ; } if ( \ is_string ( $ role ) && parent :: has ( $ role ) ) { return parent :: get ( $ role ) ; } throw new \ InvalidArgumentException ( 'Unable... | Resolves given data to a Role . |
53,434 | static function setFilesystem ( ? \ React \ Filesystem \ FilesystemInterface $ filesystem ) { if ( $ filesystem === null ) { $ filesystem = false ; } self :: $ filesystem = $ filesystem ; } | Sets the React Filesystem instance or disables it . |
53,435 | static function resolveFileResolvable ( string $ file ) { $ rfile = @ \ realpath ( $ file ) ; if ( $ rfile ) { if ( self :: $ filesystem ) { return self :: $ filesystem -> getContents ( $ file ) ; } return \ React \ Promise \ resolve ( \ file_get_contents ( $ rfile ) ) ; } elseif ( \ filter_var ( $ file , FILTER_VALIDA... | Resolves filepath and URL into file data - returns it if it s neither . Resolves with a string . |
53,436 | protected function createConnection ( int $ shardID ) { if ( empty ( $ this -> connections [ $ shardID ] ) ) { $ this -> connections [ $ shardID ] = new \ CharlotteDunois \ Yasmin \ WebSocket \ WSConnection ( $ this , $ shardID , $ this -> compression ) ; $ this -> connections [ $ shardID ] -> on ( 'close' , function (... | Creates a new ws connection for a specific shard if necessary . |
53,437 | protected function handleConnectEncoding ( array & $ querystring ) { if ( $ this -> encoding === null ) { $ encoding = $ querystring [ 'encoding' ] ?? self :: WS [ 'encoding' ] ; $ name = \ str_replace ( '-' , '' , \ ucwords ( $ encoding , '-' ) ) ; if ( \ strpos ( $ name , '\\' ) === false ) { $ name = '\\CharlotteDun... | Handles the connect encoding for the query string . |
53,438 | protected function handleConnectGateway ( string $ gateway , array & $ querystring ) { if ( ! empty ( $ querystring ) ) { if ( $ this -> compression !== '' ) { $ compression = $ this -> compression ; $ querystring [ 'compress' ] = $ compression :: getName ( ) ; } $ this -> gatewayQS = $ querystring ; $ gateway = \ rtri... | Handles the connect gateway URL in terms to the query string .. |
53,439 | function delete ( $ timeout = 0 , string $ reason = '' ) { return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) use ( $ timeout , $ reason ) { if ( $ timeout > 0 ) { $ this -> client -> addTimer ( $ timeout , function ( ) use ( $ reason , $ resolve , $ reject ) { $ this -> dele... | Deletes the message . |
53,440 | function fetchWebhook ( ) { if ( $ this -> webhookID === null ) { throw new \ BadMethodCallException ( 'Unable to fetch webhook from a message that was not posted by a webhook' ) ; } return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) { $ this -> client -> apimanager ( ) -> en... | Fetches the webhook used to create this message . Resolves with an instance of Webhook . |
53,441 | function getJumpURL ( ) { $ guild = ( $ this -> channel instanceof \ CharlotteDunois \ Yasmin \ Models \ TextChannel ? $ this -> guild -> id : '@me' ) ; return 'https://canary.discordapp.com/channels/' . $ guild . '/' . $ this -> channel -> getId ( ) . '/' . $ this -> id ; } | Returns the jump to message link for this message . |
53,442 | function react ( $ emoji ) { try { $ emoji = $ this -> client -> emojis -> resolve ( $ emoji ) ; } catch ( \ InvalidArgumentException $ e ) { if ( \ is_numeric ( $ emoji ) ) { throw $ e ; } $ match = ( bool ) \ preg_match ( '/(?:<a?:)?(.+):(\d+)/' , $ emoji , $ matches ) ; if ( $ match ) { $ emoji = $ matches [ 1 ] . '... | Reacts to the message with the specified unicode or custom emoji . Resolves with an instance of MessageReaction . |
53,443 | function reply ( string $ content , array $ options = array ( ) ) { return $ this -> channel -> send ( $ this -> author -> __toString ( ) . self :: $ replySeparator . $ content , $ options ) ; } | Replies to the message . Resolves with an instance of Message or with a Collection of Message instances mapped by their ID . |
53,444 | function prepareMessage ( string $ data ) : \ Ratchet \ RFC6455 \ Messaging \ Message { $ frame = new \ Ratchet \ RFC6455 \ Messaging \ Frame ( $ data , true , \ Ratchet \ RFC6455 \ Messaging \ Frame :: OP_BINARY ) ; $ msg = new \ Ratchet \ RFC6455 \ Messaging \ Message ( ) ; $ msg -> addFrame ( $ frame ) ; return $ ms... | Prepares the data to be sent . |
53,445 | protected function convertIDs ( $ data ) { $ arr = array ( ) ; foreach ( $ data as $ key => $ val ) { if ( \ is_string ( $ key ) && $ key [ 0 ] === ':' ) { $ key = \ mb_substr ( $ key , 1 ) ; } if ( $ val instanceof \ CharlotteDunois \ Kimberly \ Atom ) { $ arr [ $ key ] = ( string ) $ val -> atom ; } elseif ( $ val in... | Converts all IDs from integer to strings . |
53,446 | function isRichPresence ( ) { return ( $ this -> applicationID !== null || $ this -> party !== null || $ this -> sessionID !== null || $ this -> syncID !== null ) ; } | Whether this activity is a rich presence . |
53,447 | function resolve ( $ emoji ) { if ( $ emoji instanceof \ CharlotteDunois \ Yasmin \ Models \ Emoji ) { return $ emoji ; } if ( $ emoji instanceof \ CharlotteDunois \ Yasmin \ Models \ MessageReaction ) { return $ emoji -> emoji ; } if ( \ is_int ( $ emoji ) ) { $ emoji = ( string ) $ emoji ; } if ( \ is_string ( $ emoj... | Resolves given data to an emoji . |
53,448 | function ban ( int $ days = 0 , string $ reason = '' ) { return $ this -> guild -> ban ( $ this , $ days , $ reason ) ; } | Bans the guild member . |
53,449 | function getColorRole ( ) { $ roles = $ this -> roles -> filter ( function ( $ role ) { return $ role -> color ; } ) ; if ( $ roles -> count ( ) === 0 ) { return null ; } return $ roles -> reduce ( function ( $ prev , $ role ) { if ( $ prev === null ) { return $ role ; } return ( $ role -> comparePositionTo ( $ prev ) ... | Gets the role the member is displayed with . |
53,450 | function getDisplayColor ( ) { $ colorRole = $ this -> getColorRole ( ) ; if ( $ colorRole !== null && $ colorRole -> color > 0 ) { return $ colorRole -> color ; } return null ; } | Gets the displayed color of the member . |
53,451 | function getDisplayHexColor ( ) { $ colorRole = $ this -> getColorRole ( ) ; if ( $ colorRole !== null && $ colorRole -> color > 0 ) { return $ colorRole -> hexColor ; } return null ; } | Gets the displayed color of the member as hex string . |
53,452 | function getHighestRole ( ) { return $ this -> roles -> reduce ( function ( $ prev , $ role ) { if ( $ prev === null ) { return $ role ; } return ( $ role -> comparePositionTo ( $ prev ) > 0 ? $ role : $ prev ) ; } ) ; } | Gets the highest role of the member . |
53,453 | function getHoistRole ( ) { $ roles = $ this -> roles -> filter ( function ( $ role ) { return $ role -> hoist ; } ) ; if ( $ roles -> count ( ) === 0 ) { return null ; } return $ roles -> reduce ( function ( $ prev , $ role ) { if ( $ prev === null ) { return $ role ; } return ( $ role -> comparePositionTo ( $ prev ) ... | Gets the role the member is hoisted with . |
53,454 | function isBannable ( ) { if ( $ this -> id === $ this -> guild -> ownerID || $ this -> id === $ this -> client -> user -> id ) { return false ; } $ member = $ this -> guild -> me ; if ( ! $ member -> permissions -> has ( \ CharlotteDunois \ Yasmin \ Models \ Permissions :: PERMISSIONS [ 'BAN_MEMBERS' ] ) ) { return fa... | Whether the member can be banned by the client user . |
53,455 | function kick ( string $ reason = '' ) { return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) use ( $ reason ) { $ this -> client -> apimanager ( ) -> endpoints -> guild -> removeGuildMember ( $ this -> guild -> id , $ this -> id , $ reason ) -> done ( function ( ) use ( $ reso... | Kicks the guild member . |
53,456 | function permissionsIn ( $ channel ) { $ channel = $ this -> guild -> channels -> resolve ( $ channel ) ; if ( ! ( $ channel instanceof \ CharlotteDunois \ Yasmin \ Interfaces \ GuildChannelInterface ) ) { throw new \ InvalidArgumentException ( 'Given channel is not a guild channel' ) ; } return $ channel -> permission... | Returns permissions for a member in a guild channel taking into account roles and permission overwrites . |
53,457 | function delete ( string $ reason = '' ) { return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) use ( $ reason ) { $ this -> client -> apimanager ( ) -> endpoints -> channel -> deleteChannelPermission ( $ this -> channel -> getId ( ) , $ this -> id , $ reason ) -> then ( functi... | Deletes the permission overwrite . |
53,458 | function delete ( string $ reason = '' ) { return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) use ( $ reason ) { $ this -> client -> apimanager ( ) -> endpoints -> invite -> deleteInvite ( $ this -> code , $ reason ) -> done ( function ( ) use ( $ resolve ) { $ resolve ( ) ; ... | Deletes the invite . |
53,459 | function isRecipient ( $ user ) { $ user = $ this -> client -> users -> resolve ( $ user ) ; return $ this -> recipients -> has ( $ user -> id ) ; } | Determines whether a given user is a recipient of this channel . |
53,460 | static function decodeBody ( \ Psr \ Http \ Message \ ResponseInterface $ response ) { $ body = ( string ) $ response -> getBody ( ) ; $ type = $ response -> getHeader ( 'Content-Type' ) [ 0 ] ; if ( \ stripos ( $ type , 'text/html' ) !== false ) { throw new \ RuntimeException ( 'Invalid API response: HTML response bod... | Gets the response body from the response . |
53,461 | protected function handleAPIError ( \ Psr \ Http \ Message \ ResponseInterface $ response , $ body , ? \ CharlotteDunois \ Yasmin \ Interfaces \ RatelimitBucketInterface $ ratelimit = null ) { $ status = $ response -> getStatusCode ( ) ; if ( $ status >= 500 ) { $ this -> retries ++ ; $ maxRetries = ( int ) $ this -> a... | Handles an API error . |
53,462 | static function makeRequest ( \ Psr \ Http \ Message \ RequestInterface $ request , ? array $ requestOptions = null ) { $ client = static :: getHTTPClient ( ) ; if ( ! empty ( $ requestOptions ) ) { if ( isset ( $ requestOptions [ 'http_errors' ] ) ) { $ client = $ client -> withOptions ( array ( 'obeySuccessCode' => !... | Makes an asynchronous request . Resolves with an instance of ResponseInterface . |
53,463 | static function resolveURLToData ( string $ url , ? array $ requestHeaders = null ) { if ( $ requestHeaders === null ) { $ requestHeaders = array ( ) ; } foreach ( $ requestHeaders as $ key => $ val ) { unset ( $ requestHeaders [ $ key ] ) ; $ nkey = \ ucwords ( $ key , '-' ) ; $ requestHeaders [ $ nkey ] = $ val ; } i... | Asynchronously resolves a given URL to the response body . Resolves with a string . |
53,464 | static function applyRequestOptions ( \ Psr \ Http \ Message \ RequestInterface $ request , array $ requestOptions ) { if ( isset ( $ requestOptions [ 'multipart' ] ) ) { $ multipart = new \ RingCentral \ Psr7 \ MultipartStream ( $ requestOptions [ 'multipart' ] ) ; $ request = $ request -> withBody ( $ multipart ) -> ... | Applies request options to the request . |
53,465 | static function flattenErrors ( $ obj , $ key = '' ) { $ messages = array ( ) ; foreach ( $ obj as $ k => $ val ) { if ( $ k === 'message' ) { continue ; } $ newKey = $ k ; if ( $ key ) { if ( \ is_numeric ( $ k ) ) { $ newKey = $ key . '.' . $ k ; } else { $ newKey = $ key . '[' . $ k . ']' ; } } if ( isset ( $ val [ ... | Flattens an errors object returned from the API into an array . |
53,466 | static function cleanContent ( \ CharlotteDunois \ Yasmin \ Models \ Message $ message , string $ text ) { foreach ( $ message -> mentions -> channels as $ channel ) { $ text = \ str_replace ( '<#' . $ channel -> getId ( ) . '>' , '#' . $ channel -> name , $ text ) ; } foreach ( $ message -> mentions -> roles as $ role... | Cleans the text from mentions by providing a context message . |
53,467 | static function escapeMarkdown ( string $ text , bool $ onlyCodeBlock = false , bool $ onlyInlineCode = false ) { if ( $ onlyCodeBlock ) { return \ preg_replace ( '/(```)/miu' , "\\`\\`\\`" , $ text ) ; } if ( $ onlyInlineCode ) { return \ preg_replace ( '/(`)/miu' , '\\\\$1' , $ text ) ; } return \ preg_replace ( '/(\... | Escapes any Discord - flavour markdown in a string . |
53,468 | static function splitMessage ( string $ text , array $ options = array ( ) ) { $ options = \ array_merge ( \ CharlotteDunois \ Yasmin \ Models \ Message :: DEFAULT_SPLIT_OPTIONS , $ options ) ; if ( \ mb_strlen ( $ text ) > $ options [ 'maxLength' ] ) { $ i = 0 ; $ messages = array ( ) ; $ parts = \ explode ( $ options... | Splits a string into multiple chunks at a designated character that do not exceed a specific length . |
53,469 | function resolve ( $ guildmember ) { if ( $ guildmember instanceof \ CharlotteDunois \ Yasmin \ Models \ GuildMember ) { return $ guildmember ; } if ( $ guildmember instanceof \ CharlotteDunois \ Yasmin \ Models \ User ) { $ guildmember = $ guildmember -> id ; } if ( \ is_int ( $ guildmember ) ) { $ guildmember = ( str... | Resolves given data to a guildmember . |
53,470 | function collect ( ) { return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) { $ this -> resolve = $ resolve ; $ this -> reject = $ reject ; $ filter = $ this -> filter ; $ handler = $ this -> handler ; $ this -> listener = function ( ... $ item ) use ( & $ filter , & $ handler ... | Starts collecting . Resolves with a collection . |
53,471 | function stop ( ) { if ( $ this -> timer ) { self :: $ loop -> cancelTimer ( $ this -> timer ) ; $ this -> timer = null ; } $ this -> emitter -> removeListener ( $ this -> event , $ this -> listener ) ; $ errors = ( array ) ( $ this -> options [ 'errors' ] ?? array ( ) ) ; if ( \ in_array ( 'max' , $ errors , true ) &&... | This will stop the collector . |
53,472 | function comparePositionTo ( \ CharlotteDunois \ Yasmin \ Models \ Role $ role ) { if ( $ this -> position === $ role -> position ) { return $ role -> id <=> $ this -> id ; } return $ this -> position <=> $ role -> position ; } | Compares the position from the role to the given role . |
53,473 | function delete ( string $ reason = '' ) { return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) use ( $ reason ) { $ this -> client -> apimanager ( ) -> endpoints -> guild -> deleteGuildRole ( $ this -> guild -> id , $ this -> id , $ reason ) -> done ( function ( ) use ( $ reso... | Deletes the role . |
53,474 | function getCalculatedPosition ( ) { $ sorted = $ this -> guild -> roles -> sortCustom ( function ( \ CharlotteDunois \ Yasmin \ Models \ Role $ a , \ CharlotteDunois \ Yasmin \ Models \ Role $ b ) { return $ b -> comparePositionTo ( $ a ) ; } ) ; return $ sorted -> indexOf ( $ this ) ; } | Calculates the positon of the role in the Discord client . |
53,475 | function isEditable ( ) { if ( $ this -> managed ) { return false ; } $ member = $ this -> guild -> me ; if ( ! $ member -> permissions -> has ( \ CharlotteDunois \ Yasmin \ Models \ Permissions :: PERMISSIONS [ 'MANAGE_ROLES' ] ) ) { return false ; } return ( $ member -> getHighestRole ( ) -> comparePositionTo ( $ thi... | Whether the role can be edited by the client user . |
53,476 | function handleRatelimit ( ? int $ limit , ? int $ remaining , ? float $ resetTime ) { return $ this -> get ( ) -> then ( function ( $ data ) use ( $ limit , $ remaining , $ resetTime ) { if ( $ limit === null && $ remaining === null && $ resetTime === null ) { $ limit = $ data [ 'limit' ] ; $ remaining = $ data [ 'rem... | Sets the ratelimits from the response |
53,477 | function clear ( ) : void { $ queue = $ this -> queue ; $ this -> queue = array ( ) ; while ( $ item = \ array_shift ( $ queue ) ) { unset ( $ item ) ; } } | Unsets all queue items . |
53,478 | protected function get ( ) { return $ this -> cache -> get ( 'yasmin-ratelimiter-' . $ this -> endpoint , null , true ) -> then ( null , function ( ) { return array ( 'limit' => 0 , 'remaining' => 0 , 'resetTime' => null ) ; } ) ; } | Retrieves the cache data . |
53,479 | protected function set ( array $ value ) { return $ this -> cache -> set ( 'yasmin-ratelimiter-' . $ this -> endpoint , $ value ) -> then ( null , function ( \ Throwable $ e ) { if ( $ e -> getMessage ( ) !== 'Client got destroyed' ) { throw $ e ; } } ) ; } | Sets the cache data . |
53,480 | function resolve ( $ guild ) { if ( $ guild instanceof \ CharlotteDunois \ Yasmin \ Models \ Guild ) { return $ guild ; } if ( \ is_int ( $ guild ) ) { $ guild = ( string ) $ guild ; } if ( \ is_string ( $ guild ) && parent :: has ( $ guild ) ) { return parent :: get ( $ guild ) ; } throw new \ InvalidArgumentException... | Resolves given data to a guild . |
53,481 | function setAttachment ( string $ attachment , string $ filename = '' ) { $ this -> attachment = $ attachment ; $ this -> filename = $ filename ; return $ this ; } | Sets the attachment . |
53,482 | function _getMessageFilesArray ( ) { $ props = array ( 'name' => $ this -> filename ) ; $ file = @ \ realpath ( $ this -> attachment ) ; if ( $ file ) { $ props [ 'path' ] = $ file ; } elseif ( \ filter_var ( $ this -> attachment , \ FILTER_VALIDATE_URL ) ) { $ props [ 'path' ] = $ this -> attachment ; } else { $ props... | Returns a proper message files array . |
53,483 | function createWebhook ( string $ name , ? string $ avatar = null , string $ reason = '' ) { return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) use ( $ name , $ avatar , $ reason ) { if ( ! empty ( $ avatar ) ) { $ file = \ CharlotteDunois \ Yasmin \ Utils \ FileHelpers :: re... | Create a webhook for the channel . Resolves with the new Webhook instance . |
53,484 | function fetchWebhooks ( ) { return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) { $ this -> client -> apimanager ( ) -> endpoints -> webhook -> getChannelWebhooks ( $ this -> id ) -> done ( function ( $ data ) use ( $ resolve ) { $ collect = new \ CharlotteDunois \ Collect \ ... | Fetches the channel s webhooks . Resolves with a Collection of Webhook instances mapped by their ID . |
53,485 | function resolve ( $ presence ) { if ( $ presence instanceof \ CharlotteDunois \ Yasmin \ Models \ Presence ) { return $ presence ; } if ( $ presence instanceof \ CharlotteDunois \ Yasmin \ Models \ User ) { $ presence = $ presence -> id ; } if ( \ is_int ( $ presence ) ) { $ presence = ( string ) $ presence ; } if ( \... | Resolves given data to a presence . |
53,486 | function factory ( array $ data ) { $ presence = new \ CharlotteDunois \ Yasmin \ Models \ Presence ( $ this -> client , $ data ) ; $ this -> set ( $ presence -> userID , $ presence ) ; return $ presence ; } | Factory to create presences . |
53,487 | private static function initLanguageMap ( $ language = '' ) { if ( count ( self :: $ map ) > 0 && ( ( $ language == '' ) || ( $ language == self :: $ language ) ) ) { return ; } if ( isset ( self :: $ maps [ $ language ] ) && is_array ( self :: $ maps [ $ language ] ) ) { $ m = self :: $ maps [ $ language ] ; unset ( s... | Initializes the character map . |
53,488 | public static function var_dump ( $ var , $ return = false , $ expandLevel = 1 ) { self :: $ hasArray = false ; $ toggScript = 'var colToggle = function(toggID) {var img = document.getElementById(toggID);if (document.getElementById(toggID + "-collapsable").style.display == "none") {document.getElementById(toggID + "-co... | Display a variable s contents using nice HTML formatting and will properly display the value of booleans as true or false |
53,489 | public static function is_serialized ( $ data ) { if ( ! is_string ( $ data ) ) { return false ; } $ data = trim ( $ data ) ; if ( $ data === 'N;' ) { return true ; } elseif ( $ data === 'b:0;' || $ data === 'b:1;' ) { return true ; } $ length = strlen ( $ data ) ; if ( $ length < 4 || $ data [ 1 ] !== ':' || ( $ data ... | Check value to find if it was serialized . |
53,490 | public static function htmlentities ( $ string , $ preserve_encoded_entities = false ) { if ( $ preserve_encoded_entities ) { if ( defined ( 'HHVM_VERSION' ) ) { $ translation_table = get_html_translation_table ( HTML_ENTITIES , ENT_QUOTES ) ; } else { $ translation_table = get_html_translation_table ( HTML_ENTITIES , ... | Convert entities while preserving already - encoded entities . |
53,491 | public static function downcode ( $ text , $ language = '' ) { self :: initLanguageMap ( $ language ) ; if ( self :: seems_utf8 ( $ text ) ) { if ( preg_match_all ( self :: $ regex , $ text , $ matches ) ) { for ( $ i = 0 ; $ i < count ( $ matches [ 0 ] ) ; $ i ++ ) { $ char = $ matches [ 0 ] [ $ i ] ; if ( isset ( sel... | Transliterates characters to their ASCII equivalents . |
53,492 | public static function number_to_word ( $ number ) { $ number = ( string ) $ number ; if ( strpos ( $ number , '.' ) !== false ) { list ( $ number , $ decimal ) = explode ( '.' , $ number ) ; } else { $ decimal = false ; } $ output = '' ; if ( $ number [ 0 ] == '-' ) { $ output = 'negative ' ; $ number = ltrim ( $ numb... | Converts a number into the text equivalent . For example 456 becomes four hundred and fifty - six . |
53,493 | public static function calculate_percentage ( $ numerator , $ denominator , $ decimals = 2 , $ dec_point = '.' , $ thousands_sep = ',' ) { return number_format ( ( $ numerator / $ denominator ) * 100 , $ decimals , $ dec_point , $ thousands_sep ) ; } | Calculates percentage of numerator and denominator . |
53,494 | public static function secure_random_string ( $ length = 16 ) { if ( function_exists ( 'openssl_random_pseudo_bytes' ) ) { $ bytes = openssl_random_pseudo_bytes ( $ length * 2 ) ; if ( $ bytes === false ) { throw new \ LengthException ( '$length is not accurate, unable to generate random string' ) ; } return substr ( s... | Generate secure random string of given length If openssl_random_pseudo_bytes is not available then generate random string using default function |
53,495 | public static function get_gravatar ( $ email , $ size = 32 ) { if ( self :: is_https ( ) ) { $ url = 'https://secure.gravatar.com/' ; } else { $ url = 'http://www.gravatar.com/' ; } $ url .= 'avatar/' . md5 ( $ email ) . '?s=' . ( int ) abs ( $ size ) ; return $ url ; } | Return the URL to a user s gravatar . |
53,496 | public static function linkify ( $ text ) { $ text = preg_replace ( '/'/' , ''' , $ text ) ; $ section_html_pattern = '%# Rev:20100913_0900 github.com/jmrware/LinkifyURL # Section text into HTML <A> tags and everything else. ( # $1: Everything not HTML <A> t... | Turns all of the links in a string into HTML links . |
53,497 | public static function array_search_deep ( array $ array , $ search , $ field = false ) { $ search = ( string ) $ search ; foreach ( $ array as $ key => $ elem ) { $ key = ( string ) $ key ; if ( $ field ) { if ( is_object ( $ elem ) && $ elem -> { $ field } === $ search ) { return $ key ; } elseif ( is_array ( $ elem ... | Searches for a given value in an array of arrays objects and scalar values . You can optionally specify a field of the nested arrays and objects to search in . |
53,498 | public static function array_merge_deep ( array $ dest , array $ src , $ appendIntegerKeys = true ) { foreach ( $ src as $ key => $ value ) { if ( is_int ( $ key ) and $ appendIntegerKeys ) { $ dest [ ] = $ value ; } elseif ( isset ( $ dest [ $ key ] ) and is_array ( $ dest [ $ key ] ) and is_array ( $ value ) ) { $ de... | Merges two arrays recursively and returns the result . |
53,499 | public static function set_writable ( $ filename , $ writable = true ) { $ stat = @ stat ( $ filename ) ; if ( $ stat === false ) { return false ; } if ( strncasecmp ( PHP_OS , 'WIN' , 3 ) === 0 ) { return true ; } list ( $ myuid , $ mygid ) = array ( posix_geteuid ( ) , posix_getgid ( ) ) ; if ( $ writable ) { if ( $ ... | Set the writable bit on a file to the minimum value that allows the user running PHP to write to it . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.