Skip to content
SQKo edited this page Sep 7, 2021 · 31 revisions

Discord is the main object of your Discord BOT Application

__construct([array $options = [] ])

Construct the DiscordPHP BOT instance

$discord = new Discord([
    'token' => 'bot-token',
]);

Return

  • Discord the bot instance

close()

Close the DiscordPHP Bot client

$discord->close();

factory(string $class[, mixed $data = [] ][, bool $created = false ])

Allows access to the part/repository factory. Return

  • Part the bot Part Factory
  • Repository the bot Repository Factory

getChannel(string $channel_id)

Gets a channel by its snowflake ID.

$channel = $discord->getChannel('012345678910111213');

Return

getFactory()

Gets the factory.

$factory = $discord->getFactory();

Return

  • Factory the bot Factory object

getHttpClient()

Gets the HTTP client.

$httpClient = $discord->getHttpClient();

Return

  • Http the bot Http object

getLogger()

Gets the logger being used.

$logger = $discord->getLogger();

Return

  • LoggerInterface the Logger interface

getLoop()

Gets the loop being used by the bot client.

$loop = $discord->getLoop();

Return

  • LoopInterface the bot Loop interface

getVoiceClient(string $guild_id)

Gets the bot voice client from a guild ID. Returns null if there is no voice client.

$voiceClient = $discord->getVoiceClient('012345678910111213');

Return

  • VoiceClient the bot Voice Client
  • null the bot has no Voice Client

joinVoiceChannel(Channel $channel[, bool $mute = false ][, bool $deaf = true ][, LoggerInterface|null $logger = null ][, bool $check = true ])

Joins a voice channel.

$discord->joinVoiceChannel($channel);

Return

  • PromiseInterface the promise when bot has joined the voice channel

run()

Starts the bot ReactPHP event loop.

// Should be placed at bottom of the script
$discord->run();

updatePresence([Activity|null $activity = null ][, bool $idle = false ][, string $status = 'online' ][, bool $afk = false ])

Updates the bot clients presence. See Activity

$activity = new Activity($discord, [
    'name' => 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'
    'type' => Activity::TYPE_WATCHING
]);

$discord->updatePresence($activity);

Clone this wiki locally