Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

abdfnx-cemetery/bw-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bw-php

PHP client library for Botway.


Packagist

composer require abdfnx/bw-php

Usage

after creating a new php botway project, you need to use your tokens to connect with your bot.

<?php

use Discord\Discord;
use Discord\Parts\Channel\Message;
use Botway\Botway;

$botConfig = new Botway();

// Create a $discord BOT
$discord = new Discord([
    "token" => $botConfig->GetToken(),
]);

$discord->on("ready", function (Discord $discord) {
    // Listen for messages
    $discord->on("message", function (Message $message, Discord $discord) {
        // If message is from a bot
        if ($message->author->bot) {
            // Do nothing
            return;
        }

        // If message is "ping"
        if ($message->content == "ping") {
            // Reply with "pong"
            $message->reply("pong");
        }
    });
});

// Start the Bot (must be at the bottom)
$discord->run();