Download the PHP package internet/intercord without Composer

On this page you can find all versions of the php package internet/intercord. 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 intercord

InterCord

CI Coverage Packagist version PHP version Downloads

Discord webhooks for PHP: messages, rich embeds, files, components, threads and forum posts, with rate limits handled for you.

Upgrading from 2.x? See UPGRADE-3.0.md.

Installation

Requires PHP 8.3 or later. Guzzle is the default HTTP client; any PSR-18 client can be used instead.

Quick start

$url is the webhook URL from the channel's Integrations → Webhooks settings. Treat it as a password: anyone holding it can post, edit and delete as that webhook. Keep it in an environment variable or secret store, not in source control.

Webhook::fromCredentials($id, $token) builds the same thing from the two halves of the URL.

Messages

execute() sends and returns nothing. executeAndWait() waits for Discord to confirm, and returns the Message it created:

The same is available by ID, for messages you only stored the ID of:

Edits change only what you set. To remove something, clear it:

PayloadField covers Content, Embeds, Components and Attachments.

A webhook's username, avatar and text-to-speech setting can't be changed after a message is sent, so setting them on an edit throws.

Payloads

Strings, embeds and arrays of both are shorthand for a Payload. Build one directly for everything else, or to send the same message more than once:

Set AllowedMentions whenever the content includes user input. Without it, Discord's default applies and every mention in the text pings, @everyone included. AllowedMentions::none() silences them all. new AllowedMentions(users: [$userId], roles: true, everyone: false) lets through only what you list.

suppressEmbeds() hides link previews; on an edit, suppressEmbeds(false) brings them back. suppressNotifications() sends silently, and only applies to new messages.

Embeds

Up to 10 embeds can go in one message. Invalid colours and timestamps that can't be parsed throw when they're set. A string of only digits is read as a decimal colour, so prefix hex codes with #.

Threads and forum posts

Pass a thread ID to post into an existing thread. A Message remembers its thread, so edit() and delete() go to the right place:

When the webhook belongs to a forum or media channel, start a new post with a thread name and optional tags:

Files

Up to 10 files per message. $attachment->url() is the attachment:// reference embeds and components use to show an uploaded file. Files from a path are read when the request is sent, so queued messages don't hold them in memory.

When editing, Discord deletes every existing file that an upload doesn't list, including files that embeds and components show:

Edits that don't upload anything leave a message's files alone.

Components

Link buttons

Any webhook can send link buttons, up to five per row:

Interactive components (buttons that send events, select menus) only work on webhooks an application owns, and only that application receives the clicks. InterCord has no builders for them; send them as a RawComponent with Discord's component array.

Components V2

Discord's newer layout components replace content and embeds entirely:

InterCord sets the Components V2 flag for you. Content and embeds can't be combined with these components, so mixing them throws before anything is sent. Editing a message into Components V2 clears its content and embeds, which Discord requires. A message holds at most 40 components, counting nested ones.

In a Components V2 message, uploaded files only appear where a File, Thumbnail or MediaGallery shows them; a file nothing references is accepted but not shown. Once a message uses Components V2, Discord won't let an edit turn it off: editing through the Message keeps the flag for you, while an edit by ID that changes flags (such as suppressEmbeds()) is rejected by Discord.

Queues

QueuedWebhook sends payloads in order:

A payload that's still rate limited after every retry, or that gets no response, goes back on the front of the queue before the exception is rethrown, so run() resumes where it stopped. A payload Discord rejects is dropped, since sending it again would fail the same way.

Errors

Every exception InterCord throws implements Internet\InterCord\Exception\InterCordException:

Exception When
DiscordApiException Discord answered with an error. Has $status, $discordCode and $errors.
RateLimitedException Still rate limited after every retry. Extends DiscordApiException; has $retryAfter and $global.
TransportException No response at all: DNS, connection, TLS or timeout.
UnexpectedResponseException Discord reported success, but the response wasn't a valid message.
InvalidArgumentException Something was rejected before sending. Subclasses: InvalidWebhookUrlException, InvalidColorException, InvalidTimestampException.
DetachedMessageException edit() or delete() on a Message restored from serialised data.

No exception message contains the webhook token. Client exceptions aren't chained, because their messages include the full URL.

Rate limits

InterCord waits out Discord's rate limits itself. It waits before a request when the previous one emptied the bucket. On a 429, it waits Discord's retry_after and tries again, up to maxRetries times (3 by default), before throwing RateLimitedException.

Configuration

Security

Contributing

See CONTRIBUTING.md. Releases are automated from conventional commits.

License

MIT


All versions of intercord with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-json Version *
guzzlehttp/guzzle Version ^7.9
guzzlehttp/psr7 Version ^2.7
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
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 internet/intercord contains the following files

Loading the files please wait ...