Method SendMessageAsync
- Namespace
- DisCatSharp
- Assembly
- DisCatSharp.dll
SendMessageAsync(DiscordChannel, string, CancellationToken)
Sends a normal message.
public Task<DiscordMessage> SendMessageAsync(DiscordChannel channel, string content, CancellationToken cancellationToken = default)
Parameters
channelDiscordChannelThe channel to send to.
contentstringThe message content to send.
cancellationTokenCancellationTokenA token to cancel the request.
Returns
- Task<DiscordMessage>
The message that was sent.
Exceptions
- UnauthorizedException
Thrown when the client does not have the SendMessages 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.
SendMessageAsync(DiscordChannel, DiscordEmbed, CancellationToken)
Sends a message with an embed.
public Task<DiscordMessage> SendMessageAsync(DiscordChannel channel, DiscordEmbed embed, CancellationToken cancellationToken = default)
Parameters
channelDiscordChannelThe channel to send to.
embedDiscordEmbedThe embed to attach to the message.
cancellationTokenCancellationTokenA token to cancel the request.
Returns
- Task<DiscordMessage>
The message that was sent.
Exceptions
- UnauthorizedException
Thrown when the client does not have the SendMessages 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.
SendMessageAsync(DiscordChannel, string, DiscordEmbed, CancellationToken)
Sends a message with content and an embed.
public Task<DiscordMessage> SendMessageAsync(DiscordChannel channel, string content, DiscordEmbed embed, CancellationToken cancellationToken = default)
Parameters
channelDiscordChannelChannel to send to.
contentstringThe message content to send.
embedDiscordEmbedThe embed to attach to the message.
cancellationTokenCancellationTokenA token to cancel the request.
Returns
- Task<DiscordMessage>
The message that was sent.
Exceptions
- UnauthorizedException
Thrown when the client does not have the SendMessages 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.
SendMessageAsync(DiscordChannel, DiscordMessageBuilder, CancellationToken)
Sends a message with the DiscordMessageBuilder.
public Task<DiscordMessage> SendMessageAsync(DiscordChannel channel, DiscordMessageBuilder builder, CancellationToken cancellationToken = default)
Parameters
channelDiscordChannelThe channel to send the message to.
builderDiscordMessageBuilderThe message builder.
cancellationTokenCancellationTokenA token to cancel the request.
Returns
- Task<DiscordMessage>
The message that was sent.
Exceptions
- UnauthorizedException
Thrown when the client does not have the SendMessages permission if TTS is false and SendTtsMessages if TTS is true.
- 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.
SendMessageAsync(DiscordChannel, Action<DiscordMessageBuilder>, CancellationToken)
Sends a message with an Action<T>.
public Task<DiscordMessage> SendMessageAsync(DiscordChannel channel, Action<DiscordMessageBuilder> action, CancellationToken cancellationToken = default)
Parameters
channelDiscordChannelThe channel to send the message to.
actionAction<DiscordMessageBuilder>The message builder.
cancellationTokenCancellationTokenA token to cancel the request.
Returns
- Task<DiscordMessage>
The message that was sent.
Exceptions
- UnauthorizedException
Thrown when the client does not have the SendMessages permission if TTS is false and SendTtsMessages if TTS is true.
- 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.