PHP code example of hrishikesh214 / discord-php-wrapper

1. Go to this page and download the library: Download hrishikesh214/discord-php-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hrishikesh214 / discord-php-wrapper example snippets

 
$discord = new Discord\Client("Bot token here"); 

$guild = $discord->get_guild(id:your_guild_id);

$channel = $guild->get_channel(id:channel_id_here);

$channel = $guild->get_channel(name:"channel name here");

$channel = $guild->get_channel();

$channel = $guild->get_channel(id:message_id_here);

$new_message = $channel->send("message here");

    $embed = new Embed(data:[
    	'title' => 'Embed title here',
    	'desc' => 'Description of embed here',
    	'fields' => [
    		[
    			'name' => 'field1',
    			'value' => 'value1',
    			'inline' => true
    		],
    		[
    			'name' => 'field2',
    			'value' => 'value2',
    			'inline' => false
    		]
    	]
    ]);
    
    $new_message = $channel->send(embed:$embed);

    //Fetch Message from channel
    $message = $channel->get_message(id:message_id);
	
	//Edit simple messages
    $edited_msg = $message->edit(content:"new content");

	//Edit Embed = pass new embed object with new content
    $edited_msg = $message->edit(embed:$edited_embed);

    //Fetch Message from channel
    $message = $channel->get_message(id:message_id);

	//Call delete() member of message
	$message->delete();
apacheconf
composer