Download the PHP package more-cores/discord-commands without Composer

On this page you can find all versions of the php package more-cores/discord-commands. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package discord-commands

Discord Commands

Using this library you can build Discord bot commands, process inbound interactions from Discord and respond with messages.

Table of contents

Installation

Creating Messages

Creating webhook messages (they have higher rate limits):

Or using standard messaging:

Mentioning

Both Message and WebhookMessage offer the ability to mention roles.

Enriching

Certain information can be enriched on the Discord side, such as linking to channels and timestamps in the user's local time.

Linking to a Channel

Linking to a Special Channel

Embedding Timestamps

Author

Fields

Image

Thumbnail

Footer

Components

Buttons

Use dedicated classes for each button type. Because buttons are non-interactive, you'll need to wrap them with an ActionRow when adding them to a message. You can use the shorthand actionRow() to accomplish this.

SelectMenus

Role Select Menus

Mentionable Select Menus

Mentionable Select Menus

Channel Select Menus

You can also limit which channel types can be selected

Text Input

Creating Commands

Chat commands

To create a chat command, create a class like this:

You can then simply run (new MyCommand())->jsonSerialize() to generate the json payload needed to sync your command with Discord.

Handling Command Interactions

You can use our factory to hydrate objects that represent incoming interactions within Discord. Here's an example using a Laravel request object:

Request verification

Discord requires that you verify the signature of inbound requests from their system. You'll need to have this in place in order to even configure your interactions endpoint.

You'll need to run composer require simplito/elliptic-php to add the necessary dependency, then you can verify the request like this:

Laravel middleware

For Laravel applications, we've included a middleware out of the box to assist with this. You can configure a route in routes/api.php and wrap it with our verification middleware:

Then in your controller, make sure you respond to Ping with a Pong...

Responding to Interactions

You can respond to interactions by sending messages, showing modals, etc. Make sure to give the Discord docs a read (e.g. your app has 3 seconds to respond to an interaction).

Modals

To show a modal, you can simply respond to the interaction http request with your modal object:

Showing the modal

Processing modal feedback

To process processing modal feedback, make sure you're handling ModalSubmitted events.

In the below example, $commandFactory is not provided by this package, but relates to your domain. You can customize that process however you'd like.

In my case, I like for a single class to contain all the details about what happens on a Command. So I added a whenSubmitted method that looks something like this:

The key takeaway here is that Discord requires an interaction in response to the modal submission. So you'll need to respond with something.


All versions of discord-commands with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package more-cores/discord-commands contains the following files

Loading the files please wait ....