Initial commit - Last War messaging system

This commit is contained in:
2026-02-19 01:33:28 -06:00
commit 38a8447a64
2162 changed files with 216183 additions and 0 deletions

View File

@@ -0,0 +1,487 @@
=======
Channel
=======
Channels represent a Discord channel, whether it be a direct message channel, group channel, voice channel, text channel etc.
Properties
==========
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| name | type | description |
+===============================+=================================+==========================================================================================================================================================+
| id | string | id of the channel |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| name | string | name of the channel |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| type | int | type of the channel, see Channel constants |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| topic | string | topic of the channel |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| guild_id | string or null | id of the guild the channel belongs to, null if direct message |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| guild | Guild or null | guild the channel belongs to, null if direct message |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| position | int | position of the channel in the Discord client |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| is_private | bool | whether the message is a private direct message channel |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| last_message_id | string | id of the last message sent in the channel |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| bitrate | int | bitrate of the voice channel |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| recipient | `User <#user>`_ | recipient of the direct message, only for direct message channel |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| recipients | Collection of `Users <#user>`_ | recipients of the group direct message, only for group dm channels |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| nsfw | bool | whether the channel is set as NSFW |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| user_limit | int | user limit of the channel for voice channels |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| rate_limit_per_user | int | amount of time in seconds a user has to wait between messages |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| icon | string | channel icon hash |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| owner_id | string | owner of the group DM |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| application_id | string | id of the group dm creator if it was via an oauth application |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| parent_id | string | id of the parent of the channel if it is in a group |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| last_pin_timestamp | ``Carbon`` timestamp | when the last message was pinned in the channel |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| rtc_region | string | Voice region id for the voice channel, automatic when set to null. |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| video_quality_mode | int | The camera video quality mode of the voice channel, 1 when not present. |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| default_auto_archive_duration | int | Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080. |
+-------------------------------+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
Repositories
============
+------------+----------------------------+-------------------------------------------------+
| name | type | notes |
+============+============================+=================================================+
| overwrites | `Overwrite <#overwrite>`_ | Contains permission overwrites |
+------------+----------------------------+-------------------------------------------------+
| members | VoiceStateUpdate | Only for voice channels. Contains voice members |
+------------+----------------------------+-------------------------------------------------+
| messages | `Message <#message>`_ | |
+------------+----------------------------+-------------------------------------------------+
| webhooks | `Webhook <#webhook>`_ | Only available in text channels |
+------------+----------------------------+-------------------------------------------------+
| threads | `Thread <#thread>`_ | Only available in text channels |
+------------+----------------------------+-------------------------------------------------+
| invites | `Invite <#invite>`_ | |
+------------+----------------------------+-------------------------------------------------+
Set permissions of a member or role
===================================
Sets the permissions of a member or role. Takes two arrays of permissions - one for allow and one for deny. See `Channel Permissions <#permissions>`_ for a valid list of permissions. Returns nothing in a promise.
Parameters
----------
+-------+------------------------------------------+----------------------------------------+----------+
| name | type | description | default |
+=======+==========================================+========================================+==========+
| part | `Member <#member>`_ or `Role <#role>`_ | The part to apply the permissions to | required |
+-------+------------------------------------------+----------------------------------------+----------+
| allow | array | Array of permissions to allow the part | [] |
+-------+------------------------------------------+----------------------------------------+----------+
| deny | array | Array of permissions to deny the part | [] |
+-------+------------------------------------------+----------------------------------------+----------+
.. code:: php
// Member can send messages and attach files,
// but can't add reactions to message.
$channel->setPermissions($member, [
'send_messages',
'attach_files',
], [
'add_reactions',
])->done(function () {
// ...
});
Set permissions of a member or role with an Overwrite
=====================================================
Sets the permissions of a member or role, but takes an ``Overwrite`` part instead of two arrays. Returns nothing in a promise.
.. _parameters-1:
Parameters
----------
+-----------+------------------------------------------+--------------------------------------+----------+
| name | type | description | default |
+===========+==========================================+======================================+==========+
| part | `Member <#member>`_ or `Role <#role>`_ | The part to apply the permissions to | required |
+-----------+------------------------------------------+--------------------------------------+----------+
| overwrite | ``Overwrite`` part | The overwrite to apply | required |
+-----------+------------------------------------------+--------------------------------------+----------+
.. code:: php
$allow = new ChannelPermission($discord, [
'send_messages' => true,
'attach_files' => true,
]);
$deny = new ChannelPermission($discord, [
'add_reactions' => true,
]);
$overwrite = $channel->overwrites->create([
'allow' => $allow,
'deny' => $deny,
]);
// Member can send messages and attach files,
// but can't add reactions to message.
$channel->setOverwrite($member, $overwrite)->done(function () {
// ...
});
Move member to voice channel
============================
Moves a member to a voice channel if the member is already in one. Takes a `Member <#member>`_ object or member ID and returns nothing in a promise.
.. _parameters-2:
Parameters
----------
====== ============================== ================== ========
name type description default
====== ============================== ================== ========
member `Member <#member>`_ or string The member to move required
====== ============================== ================== ========
.. code:: php
$channel->moveMember($member)->done(function () {
// ...
});
// or
$channel->moveMember('123213123123213')->done(function () {
// ...
});
Muting and unmuting member in voice channel
===========================================
Mutes or unmutes a member in the voice channel. Takes a `Member <#member>`_ object or member ID and returns nothing in a promise.
.. _parameters-3:
Parameters
----------
====== ============================== ========================= ========
name type description default
====== ============================== ========================= ========
member `Member <#member>`_ or string The member to mute/unmute required
====== ============================== ========================= ========
.. code:: php
// muting a member with a member object
$channel->muteMember($member)->done(function () {
// ...
});
// unmuting a member with a member ID
$channel->unmuteMember('123213123123213')->done(function () {
// ...
});
Creating an invite
==================
Creates an invite for a channel. Takes an array of options and returns the new invite in a promise.
.. _parameters-4:
Parameters
----------
Parameters are in an array.
+-----------------------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
| name | type | description | default |
+=======================+========+==================================================================================================================================================================================+===========+
| max_age | int | Maximum age of the invite in seconds | 24 hours |
+-----------------------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
| max_uses | int | Maximum uses of the invite | unlimited |
+-----------------------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
| temporary | bool | Whether the invite grants temporary membership | false |
+-----------------------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
| unique | bool | Whether the invite should be unique | false |
+-----------------------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
| target_type | int | The type of target for this voice channel invite | |
+-----------------------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
| target_user_id | string | The id of the user whose stream to display for this invite, required if target_type is ``Invite::TARGET_TYPE_STREAM``, the user must be streaming in the channel | |
+-----------------------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
| target_application_id | string | The id of the embedded application to open for this invite, required if target_type is ``Invite::TARGET_TYPE_EMBEDDED_APPLICATION``, the application must have the EMBEDDED flag | |
+-----------------------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
.. code:: php
$channel->createInvite([
'max_age' => 60, // 1 minute
'max_uses' => 5, // 5 uses
])->done(function (Invite $invite) {
// ...
});
Bulk deleting messages
======================
Deletes many messages at once. Takes an array of messages and/or message IDs and returns nothing in a promise.
.. _parameters-5:
Parameters
----------
+----------+----------------------------------------------------+------------------------+---------+
| name | type | description | default |
+==========+====================================================+========================+=========+
| messages | array or collection of messages and/or message IDs | The messages to delete | default |
+----------+----------------------------------------------------+------------------------+---------+
| reason | string | Reason for Audit Log | |
+----------+----------------------------------------------------+------------------------+---------+
.. code:: php
$channel->deleteMessages([
$message1,
$message2,
$message3,
'my_message4_id',
'my_message5_id',
])->done(function () {
// ...
});
Getting message history
=======================
Retrieves message history with an array of options. Returns a collection of messages in a promise.
.. _parameters-6:
Parameters
----------
+--------+--------------------------------------+----------------------------------------------+---------+
| name | type | description | default |
+========+======================================+==============================================+=========+
| before | `Message <#message>`_ or message ID | Get messages before this message | |
+--------+--------------------------------------+----------------------------------------------+---------+
| after | `Message <#message>`_ or message ID | Get messages after this message | |
+--------+--------------------------------------+----------------------------------------------+---------+
| around | `Message <#message>`_ or message ID | Get messages around this message | |
+--------+--------------------------------------+----------------------------------------------+---------+
| limit | int | Number of messages to get, between 1 and 100 | 100 |
+--------+--------------------------------------+----------------------------------------------+---------+
.. code:: php
$channel->getMessageHistory([
'limit' => 5,
])->done(function (Collection $messages) {
foreach ($messages as $message) {
// ...
}
});
Limit delete messages
=====================
Deletes a number of messages, in order from the last one sent. Takes an integer of messages to delete and returns an empty promise.
.. _parameters-7:
Parameters
----------
+--------+--------+--------------------------------------------------+----------+
| name | type | description | default |
+========+========+==================================================+==========+
| value | int | number of messages to delete, in the range 1-100 | required |
+--------+--------+--------------------------------------------------+----------+
| reason | string | Reason for Audit Log | |
+--------+--------+--------------------------------------------------+----------+
.. code:: php
// deletes the last 15 messages
$channel->limitDelete(15)->done(function () {
// ...
});
Pin or unpin a message
======================
Pins or unpins a message from the channel pinboard. Takes a message object and returns the same message in a promise.
.. _parameters-8:
Parameters
----------
======= ====================== ======================== ========
name type description default
======= ====================== ======================== ========
message `Message <#message>`_ The message to pin/unpin required
reason string Reason for Audit Log
======= ====================== ======================== ========
.. code:: php
// to pin
$channel->pinMessage($message)->done(function (Message $message) {
// ...
});
// to unpin
$channel->unpinMessage($message)->done(function (Message $message) {
// ...
});
Get invites
===========
Gets the channels invites. Returns a collection of invites in a promise.
.. code:: php
$channel->getInvites()->done(function (Collection $invites) {
foreach ($invites as $invite) {
// ...
}
});
Send a message
==============
Sends a message to the channel. Takes a message builder. Returns the message in a promise.
.. _parameters-9:
Parameters
----------
+---------+-----------------------------+-------------------------+----------+
| name | type | description | default |
+=========+=============================+=========================+==========+
| message | MessageBuilder | Message content | required |
+---------+-----------------------------+-------------------------+----------+
.. code:: php
$message = MessageBuilder::new()
->setContent('Hello, world!')
->addEmbed($embed)
->setTts(true);
$channel->sendMessage($message)->done(function (Message $message) {
// ...
});
Send an embed
=============
Sends an embed to the channel. Takes an embed and returns the sent message in a promise.
.. _parameters-10:
Parameters
----------
===== ================== ================= ========
name type description default
===== ================== ================= ========
embed `Embed <#embed>`_ The embed to send required
===== ================== ================= ========
.. code:: php
$channel->sendEmbed($embed)->done(function (Message $message) {
// ...
});
Broadcast typing
================
Broadcasts to the channel that the bot is typing. Genreally, bots should *not* use this route, but if a bot takes a while to process a request it could be useful. Returns nothing in a promise.
.. code:: php
$channel->broadcastTyping()->done(function () {
// ...
});
Create a message collector
==========================
Creates a message collector, which calls a filter function on each message received and inserts it into a collection if the function returns ``true``. The collector is resolved after a specified time or limit, whichever is given or whichever happens first. Takes a callback, an array of options and returns a collection of messages in a promise.
.. _parameters-11:
Parameters
----------
======= ======== ===================================== ========
name type description default
======= ======== ===================================== ========
filter callable The callback to call on every message required
options array Array of options []
======= ======== ===================================== ========
.. code:: php
// Collects 5 messages containing hello
$channel->createMessageCollector(fn ($message) => strpos($message->content, 'hello') !== false, [
'limit' => 5,
])->done(function (Collection $messages) {
foreach ($messages as $message) {
// ...
}
});
Options
-------
One of ``time`` or ``limit`` is required, or the collector will not resolve.
+-------+------+------------------------------------------------------------------+
| name | type | description |
+=======+======+==================================================================+
| time | int | The time after which the collector will resolve, in milliseconds |
+-------+------+------------------------------------------------------------------+
| limit | int | The number of messages to be collected |
+-------+------+------------------------------------------------------------------+
Get pinned messages
===================
Returns the messages pinned in the channel. Only applicable for text channels. Returns a collection of messages in a promise.
.. code:: php
$channel->getPinnedMessages()->done(function (Collection $messages) {
foreach ($messages as $message) {
// $message->...
}
});

View File

@@ -0,0 +1,184 @@
=====
Guild
=====
Guilds represent Discord servers.
Repositories
============
+------------------------+---------------------------------------+----------------------------------------------------------------------------------+
| name | type | notes |
+========================+=======================================+==================================================================================+
| roles | `Role <#role>`_ | |
+------------------------+---------------------------------------+----------------------------------------------------------------------------------+
| emojis | `Emoji <#emoji>`_ | |
+------------------------+---------------------------------------+----------------------------------------------------------------------------------+
| members | `Member <#member>`_ | May not contain offline members, see the ```loadAllMembers`` option <#basics>`_ |
+------------------------+---------------------------------------+----------------------------------------------------------------------------------+
| channels | `Channel <#channel>`_ | |
+------------------------+---------------------------------------+----------------------------------------------------------------------------------+
| stage_instances | `StageInstance <#stage_instance>`_ | |
+------------------------+---------------------------------------+----------------------------------------------------------------------------------+
| guild_scheduled_events | `ScheduledEvent <#scheduled_event>`_ | |
+------------------------+---------------------------------------+----------------------------------------------------------------------------------+
| stickers | `Sticker <#sticker>`_ | |
+------------------------+---------------------------------------+----------------------------------------------------------------------------------+
| invites | `Invite <#invite>`_ | Not initially loaded |
+------------------------+---------------------------------------+----------------------------------------------------------------------------------+
| bans | `Ban <#ban>`_ | Not initially loaded without ```retrieveBans`` option <#basics>`_ |
+------------------------+---------------------------------------+----------------------------------------------------------------------------------+
| commands | `Command <#command>`_ | Not initially loaded |
+------------------------+---------------------------------------+----------------------------------------------------------------------------------+
| templates | `GuildTemplate <#guild_template>`_ | Not initially loaded |
+------------------------+---------------------------------------+----------------------------------------------------------------------------------+
| integrations | `Integration <#integration>`_ | Not initially loaded |
+------------------------+---------------------------------------+----------------------------------------------------------------------------------+
Creating a role
===============
Shortcut for ``$guild->roles->save($role);``. Takes an array of parameters for a role and returns a role part in a promise.
Parameters
----------
+---------------+---------+------------------------------+-----------------------+
| name | type | description | default |
+===============+=========+==============================+=======================+
| name | string | Role name | new role |
+---------------+---------+------------------------------+-----------------------+
| permissions | string | Bitwise value of permissions | @everyone permissions |
+---------------+---------+------------------------------+-----------------------+
| color | integer | RGB color value | 0 |
+---------------+---------+------------------------------+-----------------------+
| hoist | bool | Hoisted role? | false |
+---------------+---------+------------------------------+-----------------------+
| icon | string | image data for Role icon | null |
+---------------+---------+------------------------------+-----------------------+
| unicode_emoji | string | unicode emoji for Role icon | null |
+---------------+---------+------------------------------+-----------------------+
| mentionable | bool | Mentionable role? | false |
+---------------+---------+------------------------------+-----------------------+
.. code:: php
$guild->createRole([
'name' => 'New Role',
// ...
])->done(function (Role $role) {
// ...
});
Transferring ownership of guild
===============================
Transfers the ownership of the guild to another member. The bot must own the guild to be able to transfer ownership. Takes a member object or a member ID and returns nothing in a promise.
.. _parameters-1:
Parameters
----------
====== =================== ===========================
name type description
====== =================== ===========================
member Member or member ID The member to get ownership
reason string Reason for Audit Log
====== =================== ===========================
.. code:: php
$guild->transferOwnership($member)->done(...);
// or
$guild->transferOwnership('member_id')->done(...);
Unbanning a member with a User or user ID
=========================================
Unbans a member when passed a ``User`` object or a user ID. If you have the ban object, you can do ``$guild->bans->delete($ban);``. Returns nothing in a promise.
.. _parameters-2:
Parameters
----------
======= =================== =================
name type description
======= =================== =================
user_id ``User`` or user ID The user to unban
======= =================== =================
.. code:: php
$guild->unban($user)->done(...);
// or
$guild->unban('user_id')->done(...);
Querying the Guild audit log
============================
Takes an array of parameters to query the audit log for the guild. Returns an Audit Log object inside a promise.
.. _parameters-3:
Parameters
----------
+-------------+-----------------------------------+--------------------------------------------------------+
| name | type | description |
+=============+===================================+========================================================+
| user_id | string, int, ``Member``, ``User`` | Filters audit log by who performed the action |
+-------------+-----------------------------------+--------------------------------------------------------+
| action_type | ``Entry`` constants | Filters audit log by the type of action |
+-------------+-----------------------------------+--------------------------------------------------------+
| before | string, int, ``Entry`` | Retrieves audit logs before the given audit log object |
+-------------+-----------------------------------+--------------------------------------------------------+
| limit | int between 1 and 100 | Limits the amount of audit log entries to return |
+-------------+-----------------------------------+--------------------------------------------------------+
.. code:: php
$guild->getAuditLog([
'user_id' => '123456',
'action_type' => Entry::CHANNEL_CREATE,
'before' => $anotherEntry,
'limit' => 12,
])->done(function (AuditLog $auditLog) {
foreach ($auditLog->audit_log_entries as $entry) {
// $entry->...
}
});
Creating an Emoji
=================
Takes an array of parameters for an emoji and returns an emoji part in a promise. Use the second parameter to specify local file path instead.
.. _parameters-4:
Parameters
----------
+-------+--------+------------------------------------------------------------------+------------+
| name | type | description | default |
+=======+========+==================================================================+============+
| name | string | Emoji name | *required* |
+-------+--------+------------------------------------------------------------------+------------+
| image | string | image data with base64 format, ignored if file path is specified | |
+-------+--------+------------------------------------------------------------------+------------+
| roles | array | Role IDs that are allowed to use the emoji | [] |
+-------+--------+------------------------------------------------------------------+------------+
.. code:: php
$guild->createEmoji([
'name' => 'elephpant',
// ...
],
'/path/to/file.jpg',
'audit-log reason'
)->done(function (Emoji $emoji) {
// ...
});

View File

@@ -0,0 +1,64 @@
.. toctree::
:hidden:
guild
channel
member
message
user
=====
Parts
=====
Parts is the term used for the data structures inside Discord. All parts share a common set of attributes and methods.
Parts have a set list of fillable fields. If you attempt to set a field that is not accessible, it will not warn you.
To create a part object, you can use the ``new`` syntax or the ``factory`` method. For example, creating a ``Message`` part:
.. code:: php
$message = new Message($discord);
// or
$message = $discord->factory->create(Message::class);
Part attributes can be accessed similar to an object or like an array:
.. code:: php
$message->content = 'hello!';
// or
$message['content'] = 'hello!';
echo $message->content;
// or
echo $message['content'];
Filling a part with data
========================
The ``->fill(array $attributes)`` function takes an array of attributes to fill the part. If a field is found that is not fillable, it is skipped.
.. code:: php
$message->fill([
'content' => 'hello!',
]);
Getting the raw attributes of a part
====================================
The ``->getRawAttributes()`` function returns the array representation of the part.
.. code:: php
$attributes = $message->getRawAttributes();
/**
* [
* "id" => "",
* "content" => "",
* // ...
* ]
*/

View File

@@ -0,0 +1,271 @@
======
Member
======
Members represent a user in a guild. There is a member object for every guild-user relationship, meaning that there will be multiple member objects in the Discord client with the same user ID, but they will belong to different guilds.
A member object can also be serialised into a mention string. For example:
.. code:: php
$discord->on(Event::MESSAGE_CREATE, function (Message $message) {
// Hello <@member_id>!
// Note: `$message->member` will be `null` if the message originated from
// a private message, or if the member object was not cached.
$message->channel->sendMessage('Hello '.$message->member.'!');
});
Properties
==========
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| name | type | description |
+==============================+==========================================+==========================================================================================================================================================+
| user | `User <#user>`_ | the user part of the member |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| nick | string | the nickname of the member |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| avatar | ?string | The guild avatar URL of the member |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| avatar_hash | ?string | The guild avatar hash of the member |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| roles | Collection of `Roles <#role>`_ | roles the member is a part of |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| joined_at | ``Carbon`` timestamp | when the member joined the guild |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| deaf | bool | whether the member is deafened |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| mute | bool | whether the member is muted |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| pending | ?string | whether the user has not yet passed the guilds Membership Screening requirements |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| communication_disabled_until | ``?Carbon`` | when the users timeout will expire and the user will be able to communicate in the guild again, null or a time in the past if the user is not timed out |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | string | the user ID of the member |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| username | string | the username of the member |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| discriminator | string | the four digit discriminator of the member |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| displayname | string | nick/username#discriminator |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| guild | `Guild <#guild>`_ | the guild the member is a part of |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| guild_id | string | the id of the guild the member is a part of |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| string | status | the status of the member |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| game | `Activity <#activity>`_ | the current activity of the member |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| premium_since | ``Carbon`` timestamp | when the member started boosting the guild |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| activities | Collection of `Activities <#activity>`_ | the current activities of the member |
+------------------------------+------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
Ban the member
==============
Bans the member from the guild. Returns a `Ban <#ban>`_ part in a promise.
Parameters
----------
============ ====== ====================================================
name type description
============ ====== ====================================================
daysToDelete int number of days back to delete messages, default none
reason string reason for the ban
============ ====== ====================================================
.. code:: php
$member->ban(5, 'bad person')->done(function (Ban $ban) {
// ...
});
Set the nickname of the member
==============================
Sets the nickname of the member. Requires the ``MANAGE_NICKNAMES`` permission or ``CHANGE_NICKNAME`` if changing self nickname. Returns nothing in a promise.
.. _parameters-1:
Parameters
----------
==== ====== ===================================================
name type description
==== ====== ===================================================
nick string nickname of the member, null to clear, default null
==== ====== ===================================================
.. code:: php
$member->setNickname('newnick')->done(function () {
// ...
});
Move member to channel
======================
Moves the member to another voice channel. Member must already be in a voice channel. Takes a channel or channel ID and returns nothing in a promise.
.. _parameters-2:
Parameters
----------
+---------+----------------------------------+-----------------------------------+
| name | type | description |
+=========+==================================+===================================+
| channel | `Channel <#channel>`_ or string | the channel to move the member to |
+---------+----------------------------------+-----------------------------------+
.. code:: php
$member->moveMember($channel)->done(function () {
// ...
});
// or
$member->moveMember('123451231231')->done(function () {
// ...
});
Add member to role
==================
Adds the member to a role. Takes a role or role ID and returns nothing in a promise.
.. _parameters-3:
Parameters
----------
==== ========================== =============================
name type description
==== ========================== =============================
role `Role <#role>`_ or string the role to add the member to
==== ========================== =============================
.. code:: php
$member->addRole($role)->done(function () {
// ...
});
// or
$member->addRole('1231231231')->done(function () {
// ...
});
Remove member from role
=======================
Removes the member from a role. Takes a role or role ID and returns nothing in a promise.
.. _parameters-4:
Parameters
----------
==== ========================== ==================================
name type description
==== ========================== ==================================
role `Role <#role>`_ or string the role to remove the member from
==== ========================== ==================================
.. code:: php
$member->removeRole($role)->done(function () {
// ...
});
// or
$member->removeRole('1231231231')->done(function () {
// ...
});
Timeout member
==============
Times out the member in the server. Takes a carbon or null to remove. Returns nothing in a promise.
.. _parameters-5:
Parameters
----------
+------------------------------+------------------------+----------------------------------+
| name | type | description |
+==============================+========================+==================================+
| communication_disabled_until | ``Carbon`` or ``null`` | the time for timeout to lasts on |
+------------------------------+------------------------+----------------------------------+
.. code:: php
$member->timeoutMember(new Carbon('6 hours'))->done(function () {
// ...
});
// to remove
$member->timeoutMember()->done(function () {
// ...
});
Get permissions of member
=========================
Gets the effective permissions of the member: - When given a channel, returns the effective permissions of a member in a channel. - Otherwise, returns the effective permissions of a member in a guild.
Returns a `role permission <#permissions>`_ in a promise.
.. _parameters-6:
Parameters
----------
+---------+--------------------------------+--------------------------------------------------+
| name | type | description |
+=========+================================+==================================================+
| channel | `Channel <#channel>`_ or null | the channel to get the effective permissions for |
+---------+--------------------------------+--------------------------------------------------+
.. code:: php
$member->getPermissions($channel)->done(function (RolePermission $permission) {
// ...
});
// or
$member->getPermissions()->done(function (RolePermission $permission) {
// ...
});
Get guild specific avatar URL
=============================
Gets the server-specific avatar URL for the member. Only call this function if you need to change the format or size of the image, otherwise use ``$member->avatar``. Returns a string.
.. _parameters-7:
Parameters
----------
+--------+--------+--------------------------------------------------------------------------------+
| name | type | description |
+========+========+================================================================================+
| format | string | format of the image, one of png, jpg or webp, default webp and gif if animated |
+--------+--------+--------------------------------------------------------------------------------+
| size | int | size of the image, default 1024 |
+--------+--------+--------------------------------------------------------------------------------+
.. code:: php
$url = $member->getAvatarAttribute('png', 2048);
echo $url; // https://cdn.discordapp.com/guilds/:guild_id/users/:id/avatars/:avatar_hash.png?size=2048

View File

@@ -0,0 +1,322 @@
=======
Message
=======
Messages are present in channels and can be anything from a cross post to a reply and a regular message.
Properties
==========
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| name | type | description |
+========================================+=============================================+====================================================================================================+
| id | string | id of the message |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| channel_id | string | id of the channel the message was sent in |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| channel | `Channel <#channel>`_ | channel the message was sent in |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| guild_id | string or null | the unique identifier of the guild that the channel the message was sent in belongs to |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| guild | `Guild <#guild>`_ or null | the guild that the message was sent in |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| content | string | content of the message |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| type | int, `Message <#message>`_ constants | type of the message |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| mentions | Collection of `Users <#user>`_ | users mentioned in the message |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| author | `User <#user>`_ | the author of the message |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| user_id | string | id of the user that sent the message |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| member | `Member <#member>`_ | the member that sent this message, or null if it was in a private message |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| mention_everyone | bool | whether @everyone was mentioned |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| timestamp | ``Carbon`` timestamp | the time the message was sent |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| edited_timestamp | ``Carbon`` timestamp or null | the time the message was edited or null if it hasnt been edited |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| tts | bool | whether text to speech was set when the message was sent |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| attachments | Collection of `Attachments <#attachment>`_ | array of attachments |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| embeds | Collection of `Embeds <#embed>`_ | embeds contained in the message |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| nonce | string | randomly generated string for client |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| mention_roles | Collection of `Roles <#role>`_ | any roles that were mentioned in the message |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| mention_channels | Collection of `Channels <#channel>`_ | any channels that were mentioned in the message |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| pinned | bool | whether the message is pinned |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| reactions | reaction repository | any reactions on the message |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| webhook_id | string | id of the webhook that sent the message |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| activity | object | current message activity, requires rich present |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| application | object | application of the message, requires rich presence |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| application_id | string | if the message is a response to an Interaction, this is the id of the interactions application |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| message_reference | object | message that is referenced by the message |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| referenced_message | `Message <#message>`_ | the message that is referenced in a reply |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| interaction | object | the interaction which triggered the message (application commands) |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| thread | `Thread <#thread>`_ | the thread that the message was sent in |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| components | `Component <#component>`_ | sent if the message contains components like buttons, action rows, or other interactive components |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| sticker_items | `Sticker <#sticker>`_ | stickers attached to the message |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| flags | int | message flags, see below 5 properties |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| crossposted | bool | whether the message has been crossposted |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| is_crosspost | bool | whether the message is a crosspost |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| suppress_embeds | bool | whether embeds have been supressed |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| source_message_deleted | bool | whether the source message has been deleted e.g. crosspost |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| urgent | bool | whether message is urgent |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| has_thread | bool | whether this message has an associated thread, with the same id as the message |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| ephemeral | bool | whether this message is only visible to the user who invoked the Interaction |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| loading | bool | whether this message is an Interaction Response and the bot is “thinking” |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
| failed_to_mention_some_roles_in_thread | bool | this message failed to mention some roles and add their members to the thread |
+----------------------------------------+---------------------------------------------+----------------------------------------------------------------------------------------------------+
Reply to a message
==================
Sends a “reply” to the message. Returns the new message in a promise.
Parameters
----------
==== ====== ===========================
name type description
==== ====== ===========================
text string text to send in the message
==== ====== ===========================
.. code:: php
$message->reply('hello!')->done(function (Message $message) {
// ...
});
Crosspost a message
===================
Crossposts a message to any channels that are following the channel the message was sent in. Returns the crossposted message in a promise.
.. code:: php
$message->crosspost()->done(function (Message $message) {
// ...
});
Reply to a message after a delay
================================
Similar to replying to a message, also takes a ``delay`` parameter in which the reply will be sent after. Returns the new message in a promise.
.. _parameters-1:
Parameters
----------
===== ====== ========================================================
name type description
===== ====== ========================================================
text string text to send in the message
delay int time in milliseconds to delay before sending the message
===== ====== ========================================================
.. code:: php
// <@message_author_id>, hello! after 1.5 seconds
$message->delayedReply('hello!', 1500)->done(function (Message $message) {
// ...
});
React to a message
==================
Adds a reaction to a message. Takes an `Emoji <#emoji>`_ object, a custom emoji string or a unicode emoji. Returns nothing in a promise.
.. _parameters-2:
Parameters
----------
======== ============================ =======================
name type description
======== ============================ =======================
emoticon `Emoji <#emoji>`_ or string the emoji to react with
======== ============================ =======================
.. code:: php
$message->react($emoji)->done(function () {
// ...
});
// or
$message->react(':michael:251127796439449631')->done(function () {
// ...
});
// or
$message->react('😀')->done(function () {
// ...
});
Delete reaction(s) from a message
=================================
Deletes reaction(s) from a message. Has four methods of operation, described below. Returns nothing in a promise.
.. _parameters-3:
Parameters
----------
+----------+----------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| name | type | description |
+==========+==================================+========================================================================================================================================+
| type | int | type of deletion, one of ``Message::REACT_DELETE_ALL, Message::REACT_DELETE_ME, Message:REACT_DELETE_ID, Message::REACT_DELETE_EMOJI`` |
+----------+----------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| emoticon | `Emoji <#emoji>`_, string, null | emoji to delete, require if using ``DELETE_ID``, ``DELETE_ME`` or ``DELETE_EMOJI`` |
+----------+----------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| id | string, null | id of the user to delete reactions for, required by ``DELETE_ID`` |
+----------+----------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
Delete all reactions
--------------------
.. code:: php
$message->deleteReaction(Message::REACT_DELETE_ALL)->done(function () {
// ...
});
Delete reaction by current user
-------------------------------
.. code:: php
$message->deleteReaction(Message::REACT_DELETE_ME, $emoji)->done(function () {
// ...
});
Delete reaction by another user
-------------------------------
.. code:: php
$message->deleteReaction(Message::REACT_DELETE_ID, $emoji, 'member_id')->done(function () {
// ...
});
Delete all reactions of one emoji
---------------------------------
.. code:: php
$message->deleteReaction(Message::REACT_DELETE_EMOJI, $emoji)->done(function () {
// ...
});
Delete the message
==================
Deletes the message. Returns nothing in a promise.
.. code:: php
$message->delete()->done(function () {
// ...
});
Edit the message
================
Updates the message. Takes a message builder. Returns the updated message in a promise.
.. code:: php
$message->edit(MessageBuilder::new()
->setContent('new content'))->done(function (Message $message) {
// ...
});
Note fields not set in the builder will not be updated, and will retain their previous value.
Create reaction collector
=========================
Creates a reaction collector. Works similar to `Channel <#channel>`_\ s reaction collector. Takes a callback and an array of options. Returns a collection of reactions in a promise.
Options
-------
At least one of ``time`` or ``limit`` must be specified.
+-------+--------------+------------------------------------------------------------------+
| name | type | description |
+=======+==============+==================================================================+
| time | int or false | time in milliseconds until the collector finishes |
+-------+--------------+------------------------------------------------------------------+
| limit | int or false | amount of reactions to be collected until the collector finishes |
+-------+--------------+------------------------------------------------------------------+
.. code:: php
$message->createReactionCollector(function (MessageReaction $reaction) {
// return true or false depending on whether you want the reaction to be collected.
return $reaction->user_id == '123123123123';
}, [
// will resolve after 1.5 seconds or 2 reactions
'time' => 1500,
'limit' => 2,
])->done(function (Collection $reactions) {
foreach ($reactions as $reaction) {
// ...
}
});
Add embed to message
====================
Adds an embed to a message. Takes an embed object. Will overwrite the old embed (if there is one). Returns the updated message in a promise.
.. _parameters-4:
Parameters
----------
===== ================== ================
name type description
===== ================== ================
embed `Embed <#embed>`_ the embed to add
===== ================== ================
.. code:: php
$message->addEmbed($embed)->done(function (Message $message) {
// ...
});

View File

@@ -0,0 +1,128 @@
====
User
====
User represents a user of Discord. The bot can “see” any users that to a guild that they also belong to.
Properties
==========
+---------------+---------+--------------------------------------------------------------------------+
| name | type | description |
+===============+=========+==========================================================================+
| id | string | id of the user |
+---------------+---------+--------------------------------------------------------------------------+
| username | string | username of the user |
+---------------+---------+--------------------------------------------------------------------------+
| discriminator | string | four-digit discriminator of the user |
+---------------+---------+--------------------------------------------------------------------------+
| displayname | string | username#discriminator |
+---------------+---------+--------------------------------------------------------------------------+
| avatar | string | avatar URL of the user |
+---------------+---------+--------------------------------------------------------------------------+
| avatar_hash | string | avatar hash of the user |
+---------------+---------+--------------------------------------------------------------------------+
| bot | bool | whether the user is a bot |
+---------------+---------+--------------------------------------------------------------------------+
| system | bool | whetehr the user is a system user e.g. Clyde |
+---------------+---------+--------------------------------------------------------------------------+
| mfa_enabled | bool | whether the user has multifactor authentication enabled |
+---------------+---------+--------------------------------------------------------------------------+
| banner | ?string | the banner URL of the user. |
+---------------+---------+--------------------------------------------------------------------------+
| banner_hash | ?string | the banner URL of the user. |
+---------------+---------+--------------------------------------------------------------------------+
| accent_color | ?int | the users banner color encoded as an integer representation |
+---------------+---------+--------------------------------------------------------------------------+
| locale | ?string | locale of the user |
+---------------+---------+--------------------------------------------------------------------------+
| verified | bool | whether the user is verified |
+---------------+---------+--------------------------------------------------------------------------+
| email | ?string | email of the user |
+---------------+---------+--------------------------------------------------------------------------+
| flags | ?int | user flags, see the ``User`` classes constants. use bit masks to compare |
+---------------+---------+--------------------------------------------------------------------------+
| premium_type | ?int | type of nitro, see the ``User`` classes constants |
+---------------+---------+--------------------------------------------------------------------------+
| public_flags | ?int | see flags above |
+---------------+---------+--------------------------------------------------------------------------+
Get private channel for user
============================
Gets the private direct message channel for the user. Returns a `Channel <#channel>`_ in a promise.
.. code:: php
$user->getPrivateChannel()->done(function (Channel $channel) {
// ...
});
Send user a message
===================
Sends a private direct message to the user. Note that your bot account can be suspended for doing this, consult Discord documentation for more information. Returns the message in a promise.
Parameters
----------
======= ====== =============================================
name type description
======= ====== =============================================
message string content to send
tts bool whether to send the message as text to speech
embed Embed embed to send in the message
======= ====== =============================================
.. code:: php
$user->sendMessage('Hello, world!', false, $embed)->done(function (Message $message) {
// ...
});
Get avatar URL
==============
Gets the avatar URL for the user. Only call this function if you need to change the format or size of the image, otherwise use ``$user->avatar``. Returns a string.
.. _parameters-1:
Parameters
----------
+--------+--------+-------------------------------------------------------------------------------+
| name | type | description |
+========+========+===============================================================================+
| format | string | format of the image, one of png, jpg or webp, default webp or gif if animated |
+--------+--------+-------------------------------------------------------------------------------+
| size | int | size of the image, default 1024 |
+--------+--------+-------------------------------------------------------------------------------+
.. code:: php
$url = $user->getAvatarAttribute('png', 2048);
echo $url; // https://cdn.discordapp.com/avatars/:user_id/:avatar_hash.png?size=2048
Get banner URL
==============
Gets the banner URL for the user. Only call this function if you need to change the format or size of the image, otherwise use ``$user->banner``. Returns a string or ``null`` if user has no banner image set.
.. _parameters-2:
Parameters
----------
+--------+--------+------------------------------------------------------------------------------+
| name | type | description |
+========+========+==============================================================================+
| format | string | format of the image, one of png, jpg or webp, default png or gif if animated |
+--------+--------+------------------------------------------------------------------------------+
| size | int | size of the image, default 600 |
+--------+--------+------------------------------------------------------------------------------+
.. code:: php
$url = $user->getBannerAttribute('png', 1024);
echo $url; // https://cdn.discordapp.com/banners/:user_id/:banner_hash.png?size=1024