Exemplo n.º 1
0
        /// <summary>
        /// Sends a message to this channel.
        /// </summary>
        /// <param name="builder">The builder with all the items to send.</param>
        /// <returns>The sent message.</returns>
        /// <exception cref="Exceptions.UnauthorizedException">Thrown when the client does not have the <see cref="Permissions.SendMessages"/> permission TTS is true and <see cref="Permissions.SendTtsMessages"/> if TTS is true.</exception>
        /// <exception cref="Exceptions.NotFoundException">Thrown when the channel does not exist.</exception>
        /// <exception cref="Exceptions.BadRequestException">Thrown when an invalid parameter was provided.</exception>
        /// <exception cref="Exceptions.ServerErrorException">Thrown when Discord is unable to process the request.</exception>
        public Task <DiscordMessage> SendMessageAsync(DiscordMessageBuilder builder)
        {
            if (this.Type != ChannelType.Text && this.Type != ChannelType.Private && this.Type != ChannelType.Group && this.Type != ChannelType.News)
            {
                throw new ArgumentException("Cannot send a text message to a non-text channel.");
            }

            if (builder.Files.Count() > 0)
            {
                return(this.Discord.ApiClient.UploadFilesAsync(this.Id, builder._files, builder.Content, builder.IsTTS, builder.Embed, builder.Mentions, builder.MentionOnReply, builder.ReplyId));
            }
            else
            {
                return(this.Discord.ApiClient.CreateMessageAsync(this.Id, builder.Content, builder.IsTTS, builder.Embed, builder.Mentions, builder.MentionOnReply, builder.ReplyId));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Sends a message to this channel.
 /// </summary>
 /// <param name="builder">The builder with all the items to send.</param>
 /// <returns>The sent message.</returns>
 /// <exception cref="Exceptions.UnauthorizedException">Thrown when the client does not have the <see cref="Permissions.SendMessages"/> permission TTS is true and <see cref="Permissions.SendTtsMessages"/> if TTS is true.</exception>
 /// <exception cref="Exceptions.NotFoundException">Thrown when the channel does not exist.</exception>
 /// <exception cref="Exceptions.BadRequestException">Thrown when an invalid parameter was provided.</exception>
 /// <exception cref="Exceptions.ServerErrorException">Thrown when Discord is unable to process the request.</exception>
 public Task <DiscordMessage> SendMessageAsync(DiscordMessageBuilder builder)
 => this.Discord.ApiClient.CreateMessageAsync(this.Id, builder);
Exemplo n.º 3
0
 /// <summary>
 /// Responds to the message.
 /// </summary>
 /// <param name="builder">The Discord Mesage builder.</param>
 /// <returns>The sent message.</returns>
 /// <exception cref="Exceptions.UnauthorizedException">Thrown when the client does not have the <see cref="Permissions.SendMessages"/> permission.</exception>
 /// <exception cref="Exceptions.NotFoundException">Thrown when the member does not exist.</exception>
 /// <exception cref="Exceptions.BadRequestException">Thrown when an invalid parameter was provided.</exception>
 /// <exception cref="Exceptions.ServerErrorException">Thrown when Discord is unable to process the request.</exception>
 public Task <DiscordMessage> RespondAsync(DiscordMessageBuilder builder)
 => this.Discord.ApiClient.CreateMessageAsync(this.ChannelId, builder);