> For the complete documentation index, see [llms.txt](https://phpdiscordsdk.gitbook.io/sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://phpdiscordsdk.gitbook.io/sdk/apis/setactivity.md).

# 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 %}
