Git Product home page Git Product logo

discordwebhook's Introduction

DiscordWebhook

Discord Webhook lightweight library for PHP

Language: English, Polski

Feel free to extend the library: Discord Webhook Documentation: https://discordapp.com/developers/docs/resources/webhook#execute-webhook

Requirements

Software you need to have installed before you can use this project:

Local or dedicated server:

They work almost the same way.

Then you need the right PHP version. Below v7 won't work.

  • PHP — version 7+

Installation

Download or clone the repository. Place the project in your server folder — folder www for WAMP server and folder http for XAMPP server (when not changed).

Examples

I created many examples to show you how you can use this library. I'm sure that everyone will find something for yourself.

Open your browser and type:

http://localhost/DiscordWebhook/examples/send-message

or

http://localhost:80/DiscordWebhook/examples/send-message

  • localhost:80 — host and the port that your server is listening on; it can be changed in server configuration
  • DiscordWebhook — folder with the project
  • examples — folder with all examples
  • send-message — example folder; you can change the name of the folder and modify the URL

Usage

https://www.youtube.com/playlist?list=PLyBTvYfUy4lGoC9R1-Db_3OWZlevO8Hpv

Simple example:

Website example

// load Webhook
require_once "../../LoadWebhook.php";

$username = "__BOT_USERNAME__";
$avatar_url = "__LINK_TO_AVATAR__";

$msg = new DiscordWebhook($webhook["url"]);

$msg->setUsername($username)->setAvatar($avatar_url)->send();

Simple embed example:

Website example

Discord example

// load Webhook
require_once "../../LoadWebhook.php";

$username = "__BOT_USERNAME__";
$avatar_url = "__LINK_TO_AVATAR__";

$embed = new DiscordEmbed();
// basic settings
$embed->setTitle("title", "https://www.magictm.com/")->setDescription("description");

$msg->setUsername($username)->setAvatar($avatar_url)->setEmbed($embed)->send();

The library supports method chaining. This is optional, so you can use both options.

No-Method-Chaining:

...
$msg = new DiscordWebhook($webhook["url"]);

$msg->setUsername($username);
$msg->setAvatar($avatar_url);
$msg->send();
...

Method-Chaining:

...
$msg = new DiscordWebhook($webhook["url"]);

$msg->setUsername($username)->setAvatar($avatar_url)->send();
...

License

MIT

discordwebhook's People

Contributors

m7rlin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.