# setActivity

{% hint style="danger" %}
**Cannot be used outside of bot listener event**

Requires

* activity
* status
* type
  {% endhint %}

{% tabs %}
{% tab title="bot.php" %}

```php
<?php
require('vendor/autoload.php');

use \HobsRkm\SDK\PHPDiscordSDK\PHPDiscordSDKFactory;

PHPDiscordSDKFactory::getInstance()
    ->botConnect("<<<<BOT TOKEN><<<<")
    ->then( 
        function ($bot) {
            $bot->on('message', function ($event) {
                PHPDiscordSDKFactory::getInstance()
                ->formatEvent($event)
                ->then(function($message){
                 //All events sent from client will be available here
                /**
                call Presence API
                discord has a delay to update your status not to often
                status - dnd | offline |online | afk
                type - one of PLAYING,STREAMING,
                LISTENING,WATCHING,COMPETING
                **/
                PHPDiscordSDKFactory::getInstance('Presence')
                ->setActivity(
                    array(
                        "activity"=>"Playing CS:GO",
                        "status"=>"dnd",
                        "type"=>'PLAYING'
                        )
                    );                        
                }, function ($reason) {
                    //message event errors
                    print_r($reason->getMessage());
                    //echo $reason->getMessage();
                });
            });
        },
        function ($reason) {
            print_r($reason);
            //other errors, bot startup, authentication
        }
    );


```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://phpdiscordsdk.gitbook.io/sdk/apis/setactivity.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
