-
Notifications
You must be signed in to change notification settings - Fork 237
Invite
Invites are part of Channel.
use Discord\Parts\Channel\Invite;
An invite to a Channel and Guild.
Requires GUILD_INVITES
intent
Your BOT must have create_instant_invite
permission
You must first get the Channel object to use the code below
Create an $invite
to $channel
with topic 60 seconds expiry and 5 limits:
$channel->createInvite([
// All options are optional
'max_age' => 60, // 1 minute
'max_uses' => 5, // 5 uses
// more options in Docs
])->then(function (Invite $invite) {
echo "Here is the invite link: {$invite->invite_url}";
})->done();
https://discord.com/developers/docs/resources/channel#create-channel-invite
You must first get the Channel object to use the code below.
Get all $invites
to $channel
:
$channel->getInvites()->then(function (Collection $invites) {
foreach ($invites as $invite) {
// ...
}
})->done();
https://discord.com/developers/docs/resources/channel#get-channel-invites
You must first get the Guild object to use the code below. Change abc123
below with the Invite code you want to retrieve
Cached, synchronous:
$invite = $guild->invites->get('code', 'abc123');
If the code above returns null
, you may need to fetch it first (Promise, asynchronous):
$guild->invites->fetch('abc123')->then(function (Invite $invite) {
// ...
})->done();
https://discord.com/developers/docs/resources/invite#get-invite
Note: This wiki is currently Work In Progress. Consider reading the docs instead.
- Application Command (Slash based)
Command Client (Message based)
- Activity
- Application
- Guild
- Private Channel
- User
Components
-
ActionRow
- Buttons
- Option (commands)
- SelectMenu
- TextInput
Builders