Skip to content

Instantly share code, notes, and snippets.

@djekl
Forked from mpociot/README.md
Created October 28, 2018 19:13
Show Gist options
  • Save djekl/d183e77f7c74ab1e10c6768a93080d1b to your computer and use it in GitHub Desktop.
Save djekl/d183e77f7c74ab1e10c6768a93080d1b to your computer and use it in GitHub Desktop.
Discord + BotMan example

BotMan - Discord example chatbot

Once you set up your discord bot, you need to add it to your server:

Look up your chatbot's client ID and visit this URL:

https://discordapp.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&scope=bot&permissions=0

Run the discord.php file through CLI:

php discord.php
<?php
use React\EventLoop\Factory;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Drivers\DriverManager;
use BotMan\Drivers\Discord\DiscordDriver;
require_once 'vendor/autoload.php';
DriverManager::loadDriver(DiscordDriver::class);
$loop = Factory::create();
$botman = BotManFactory::createForDiscord([
'discord' => [
'token' => 'YOUR-TOKEN',
]
], $loop);
$botman->hears('hello', function($botman) {
$botman->reply('Hi there!');
});
$loop->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment