Giter VIP home page Giter VIP logo

discodian's Introduction

Packagist Packagist Packagist Join our Discord server

Discodian

Discodian (Discord Custodian), the extensible php toolkit to create your own Discord bot.

Please note sharding is not yet supported.

Requirements

  • PHP 7.1 or up.
  • Some knowledge about composer.

Installation

composer create-project discodian/discodian

Configuration

Make sure to get a bot token from the developer portal.

  • New App.
  • Under section "Bot" click "Create a Bot User".
  • Under section "Bot" click "click to reveal" next to Token. This is the bot token.
  • Feel free to configure the bot to your liking.

Copy .env.example to .env if it doesn't exist yet and add any necessary configuration settings.

Run

Fire up the bot using the following command:

php discodian

Possibly you'd like to have your bot run in production permanently. The easiest way to do so is using supervisor. Here's an example config you can use (assuming your bot is installed in /home/bot:

[program:your-bot]
process_name=%(program_name)s
command=php /home/bot/discodian
autostart=true
autorestart=true
user=bot
numprocs=1
redirect_stderr=true
stdout_logfile=/home/bot/bot.log

Extensions

Create a composer-based package and make sure you use type "discodian-extension" in the composer.json definition. Here's an excerpt to give an indication;

{
    "name": "github-username/discodian-amazing-extension",
    "description": "Kick ass awesome extension for Discodian",
    "type": "discodian-extension"
}

In the root path of your package create a file bootstrap.php, you can use this file to hook into the Discodian ecosystem.

<?php

use Illuminate\Contracts\Events\Dispatcher;

return function (Dispatcher $events) {
    $events->listen(x, function () {
        
    });
};

Developing the extension

I recommend creating a workbench directory inside the project. For each extension you write you can create a folder, eg amazing-extension which houses your extension composer.json file and the bootstrap.php file.

Use Studio while in the project directory to load the extension. This generates a studio.json file. You can now install your extension from the project directory using composer require github-username/discodian-amazing-extension. This will generate a symlink from the vendor folder to your workbench.

Contributing

We adhere to the PSR standards. If you're interested in working on a Pull Request make sure to open one early on, simply prefix it with "WIP" to indicate a "Work in Progress" version. This allows early guidance towards the best result and less wasted time on your and our behalf.

In case your contribution is merged into a package of Discodian, you grant Discodian full permission to use your contribution without any need for attribution.

Credits

Part of this library was copied from and inspired by the Team Reflex source copyrighted by David Cole. Although the license claim has been dropped for some files, attribution is provided via this readme. Thank you for the hard work, it is very much appreciated!

discodian's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

discodian's Issues

Provide tutorial

Provide a step by step tutorial on how to get the bot installed and writing the first extension.

Receiving webhooks

It would be great to have the bot be configured to accept http webhook connections from GitHub, GitLab and other services. In order to do so we need to;

  • create a public directory with an index
  • possibly modify Application to process the request
  • allow extensions to listen to the requests and based on specific requirements process them, eg:
    • headers
    • route match

Realtime addition

The bot listens to a asynchronous connection. In order to work with events not only inside the bot, but also inside (for instance) a public facing web application we need to implement a websocket of our own. Laravel natively supports pusher, with a custom extension we can have events distributed to pusher and thus to a possible web page or other listener.

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.