Table of Contents

Method CreateInviteAsync

Namespace
DSharpPlus.Entities
Assembly
DSharpPlus.dll

CreateInviteAsync(int, int, bool, bool, string, DiscordInviteTargetType?, ulong?, ulong?)

Create a new invite object

public Task<DiscordInvite> CreateInviteAsync(int max_age = 86400, int max_uses = 0, bool temporary = false, bool unique = false, string reason = null, DiscordInviteTargetType? targetType = null, ulong? targetUserId = null, ulong? targetApplicationId = null)

Parameters

max_age int

Duration of invite in seconds before expiry, or 0 for never. Defaults to 86400.

max_uses int

Max number of uses or 0 for unlimited. Defaults to 0

temporary bool

Whether this invite only grants temporary membership. Defaults to false.

unique bool

If true, don't try to reuse a similar invite (useful for creating many unique one time use invites)

reason string

Reason for audit logs.

targetType DiscordInviteTargetType?

The target type of the invite, for stream and embedded application invites.

targetUserId ulong?

The ID of the target user.

targetApplicationId ulong?

The ID of the target application.

Returns

Task<DiscordInvite>

Exceptions

UnauthorizedException

Thrown when the client does not have the CreateInvite permission.

NotFoundException

Thrown when the channel does not exist.

BadRequestException

Thrown when an invalid parameter was provided.

ServerErrorException

Thrown when Discord is unable to process the request.