-
-
Notifications
You must be signed in to change notification settings - Fork 249
Discord
Discord is the main object of your Discord BOT Application
Construct the DiscordPHP BOT instance
$discord = new Discord([
'token' => 'bot-token',
]);Return
- Discord the bot instance
Close the DiscordPHP Bot client
$discord->close();Allows access to the part/repository factory.
The use of factory with part is possible with the new Part($discord, $data, $created);
// Preferred way
$channel = new Channel($discord, ['name' = 'newchannel']);
// Is equivalent to:
$channel = $discord->factory(Channel::class, ['name' => 'newchannel']);Return
- Part the bot Part Factory
- Repository the bot Repository Factory
Gets a channel by its snowflake ID.
$channel = $discord->getChannel('012345678910111213');Return
- Channel the channel or private channel part
Gets the factory.
$factory = $discord->getFactory();Return
- Factory the bot Factory object
Gets the HTTP client.
$httpClient = $discord->getHttpClient();Return
- Http the bot Http object
Gets the logger being used.
$logger = $discord->getLogger();Return
- LoggerInterface the Logger interface
Gets the loop being used by the bot client.
$loop = $discord->getLoop();Return
- LoopInterface the bot Loop interface
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
-
nullthe bot has no Voice Client
joinVoiceChannel(Channel $channel[, bool $mute = false ][, bool $deaf = true ][, LoggerInterface $logger = null ][, bool $check = true ])
Joins a voice channel.
$discord->joinVoiceChannel($channel)->then(function (VoiceClient $vc) {
echo "Joined voice channel.\r\n";
$vc->playFile('myfile.mp3');
}, function ($e) {
echo "There was an error joining the voice channel: {$e->getMessage()}\r\n";
});Return
- PromiseInterface the promise when bot has joined the voice channel
Starts the bot ReactPHP event loop.
// Should be placed at bottom of the script
$discord->run();updatePresence([Activity $activity = null ][, bool $idle = false ][, string $status = 'online' ][, bool $afk = false ])
Updates the bot clients presence. See Activity
API Documentation: https://discord.com/developers/docs/topics/gateway#update-presence
$activity = new Activity($discord, [
'name' => 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'
'type' => Activity::TYPE_WATCHING
]);
$discord->updatePresence($activity);Note: This wiki is currently Work In Progress. Consider reading the docs instead.
- Application Command (Slash based)
Command Client (Message based)
- Activity
- Application
- Guild
- Private Channel
- User
Components
-
ActionRow
- Buttons
- Option (commands)
- SelectMenu
- TextInput
Builders