/// <summary> /// Responds to the message. /// </summary> /// <param name="content">Message content to respond with.</param> /// <param name="embed">Embed to attach to the message.</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(string content, DiscordEmbed embed) => this.Discord.ApiClient.CreateMessageAsync(this.ChannelId, content, null, embed, null);
/// <summary> /// Responds to the message with several files. /// </summary> /// <param name="files">A filename to data stream mapping.</param> /// <param name="content">Message content to respond with.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public Task <DiscordMessage> RespondWithFilesAsync(Dictionary <string, Stream> files, string content = null, bool tts = false, DiscordEmbed embed = null) => this.Discord.ApiClient.UploadFilesAsync(ChannelId, files, content, tts, embed);
/// <summary> /// Sends a message to this channel. /// </summary> /// <param name="content">Content of the message to send.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public Task<DiscordMessage> SendMessageAsync(string content = null, bool tts = false, DiscordEmbed embed = null) { if (this.Type != ChannelType.Text && this.Type != ChannelType.Private && this.Type != ChannelType.Group) throw new ArgumentException("Cannot send a text message to a non-text channel"); if (string.IsNullOrWhiteSpace(content) && embed == null) throw new ArgumentNullException("Must provide either content, embed or both, and content may not consist only of whitespace"); if (content != null && content.Length > 2000) throw new ArgumentException("Message must be less than or exactly 2000 characters", nameof(content)); return this.Discord.ApiClient.CreateMessageAsync(Id, content, tts, embed); }
/// <summary> /// Sends a direct message with a file attached to this member. Creates a direct message channel if one does not exist already. /// </summary> /// <param name="fileData">Stream containing the data to attach as a file.</param> /// <param name="content">Content of the message to send.</param> /// <param name="is_tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public async Task<DiscordMessage> SendFileAsync(FileStream fileData, string content = null, bool is_tts = false, DiscordEmbed embed = null) { var chn = await this.CreateDmChannelAsync().ConfigureAwait(false); return await chn.SendFileAsync(fileData, content, is_tts, embed).ConfigureAwait(false); }
/// <summary> /// Responds to the message with a file. /// </summary> /// <param name="filePath">Path to the file to be attached to the message.</param> /// <param name="content">Message content to respond with.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public async Task <DiscordMessage> RespondWithFileAsync(string filePath, string content = null, bool tts = false, DiscordEmbed embed = null) { using (var fs = File.OpenRead(filePath)) return(await this.Discord.ApiClient.UploadFileAsync(this.ChannelId, fs, Path.GetFileName(fs.Name), content, tts, embed).ConfigureAwait(false)); }
/// <summary> /// Sends a message to this channel. /// </summary> /// <param name="content">Content of the message to send.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public Task <DiscordMessage> SendMessageAsync(string content = null, bool tts = false, DiscordEmbed embed = null) { if (this.Type != ChannelType.Text && this.Type != ChannelType.Private && this.Type != ChannelType.Group) { throw new ArgumentException("Cannot send a file to a non-text channel"); } return(this.Discord.ApiClient.CreateMessageAsync(Id, content, tts, embed)); }
/// <summary> /// Sends a message containing an attached file to this channel. /// </summary> /// <param name="file_path">Path to the file to be attached to the message.</param> /// <param name="content">Content of the message to send.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public async Task <DiscordMessage> SendFileAsync(string file_path, string content = null, bool tts = false, DiscordEmbed embed = null) { if (this.Type != ChannelType.Text && this.Type != ChannelType.Private && this.Type != ChannelType.Group) { throw new ArgumentException("Cannot send a file to a non-text channel"); } using (var fs = File.OpenRead(file_path)) return(await this.Discord.ApiClient.UploadFileAsync(this.Id, fs, Path.GetFileName(fs.Name), content, tts, embed)); }
/// <summary> /// Sends a direct message with several files attached to this member. Creates a direct message channel if one does not exist already. /// </summary> /// <param name="files">Dictionary of filename to data stream containing the data to upload as files.</param> /// <param name="content">Content of the message to send.</param> /// <param name="is_tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public async Task <DiscordMessage> SendMultipleFilesAsync(Dictionary <string, Stream> files, string content = null, bool is_tts = false, DiscordEmbed embed = null) { if (this.IsBot && this.Discord.CurrentUser.IsBot) { throw new ArgumentException("Bots cannot DM each other"); } var chn = await this.CreateDmChannelAsync().ConfigureAwait(false); return(await chn.SendMultipleFilesAsync(files, content, is_tts, embed).ConfigureAwait(false)); }
/// <summary> /// Responds to the message with a file. /// </summary> /// <param name="fileName">Name of the file to be attached.</param> /// <param name="fileData">Stream containing the data to attach to the message as a file.</param> /// <param name="content">Message content to respond with.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <param name="mentions">Allowed mentions in the message</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> RespondWithFileAsync(string fileName, Stream fileData, string content = null, bool tts = false, DiscordEmbed embed = null, IEnumerable <IMention> mentions = null) => this.Discord.ApiClient.UploadFileAsync(this.ChannelId, fileData, fileName, content, tts, embed, mentions);
/// <summary> /// Sends a message containing an attached file to this channel. /// </summary> /// <param name="file_path">Path to the file to be attached to the message.</param> /// <param name="content">Content of the message to send.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public async Task <DiscordMessage> SendFileAsync(string file_path, string content = null, bool tts = false, DiscordEmbed embed = null) { using (var fs = File.OpenRead(file_path)) return(await this.Discord.ApiClient.UploadFileAsync(this.Id, fs, Path.GetFileName(fs.Name), content, tts, embed)); }
/// <summary> /// Sends a message with several attached files to this channel. /// </summary> /// <param name="files">A filename to data stream mapping.</param> /// <param name="content">Content of the message to send.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public Task <DiscordMessage> SendMultipleFilesAsync(Dictionary <string, Stream> files, string content = "", bool tts = false, DiscordEmbed embed = null) => this.Discord.ApiClient.UploadFilesAsync(Id, files, content, tts, embed);
/// <summary> /// Sends a message containing an attached file to this channel. /// </summary> /// <param name="file_data">Stream containing the data to attach to the message as a file.</param> /// <param name="file_name">Name of the file to attach to the message.</param> /// <param name="content">Content of the message to send.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public Task <DiscordMessage> SendFileAsync(Stream file_data, string file_name, string content = null, bool tts = false, DiscordEmbed embed = null) => this.Discord.ApiClient.UploadFileAsync(this.Id, file_data, file_name, content, tts, embed);
/// <summary> /// Sends a message with several attached files to this channel. /// </summary> /// <param name="files">A filename to data stream mapping.</param> /// <param name="content">Content of the message to send.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <param name="mentions">Allowed mentions in the message</param> /// <returns>The sent message.</returns> public Task <DiscordMessage> SendMultipleFilesAsync(Dictionary <string, Stream> files, string content = "", bool tts = false, DiscordEmbed embed = null, IEnumerable <IMention> mentions = null) { if (this.Type != ChannelType.Text && this.Type != ChannelType.Private && this.Type != ChannelType.Group && this.Type != ChannelType.News) { throw new ArgumentException("Cannot send a file to a non-text channel."); } if (files.Count > 10) { throw new ArgumentException("Cannot send more than 10 files with a single message."); } return(this.Discord.ApiClient.UploadFilesAsync(this.Id, files, content, tts, embed, mentions)); }
/// <summary> /// Sends a message containing an attached file to this channel. /// </summary> /// <param name="fileData">Stream containing the data to attach to the message as a file.</param> /// <param name="fileName">Name of the file to attach to the message.</param> /// <param name="content">Content of the message to send.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <param name="mentions">Allowed mentions in the message</param> /// <returns>The sent message.</returns> public Task <DiscordMessage> SendFileAsync(string fileName, Stream fileData, string content = null, bool tts = false, DiscordEmbed embed = null, IEnumerable <IMention> mentions = null) { if (this.Type != ChannelType.Text && this.Type != ChannelType.Private && this.Type != ChannelType.Group && this.Type != ChannelType.News) { throw new ArgumentException("Cannot send a file to a non-text channel."); } return(this.Discord.ApiClient.UploadFileAsync(this.Id, fileData, fileName, content, tts, embed, mentions)); }
/// <summary> /// Sends a direct message with a file attached to this member. Creates a direct message channel if one does not exist already. /// </summary> /// <param name="file_path">Path to the file to attach to the message.</param> /// <param name="content">Content of the message to send.</param> /// <param name="is_tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public async Task <DiscordMessage> SendFileAsync(string file_path, string content = null, bool is_tts = false, DiscordEmbed embed = null) { var chn = await this.CreateDmChannelAsync(); return(await chn.SendFileAsync(file_path, content, is_tts, embed)); }
/// <summary> /// Responds to the message with several files. /// </summary> /// <param name="files">A filename to data stream mapping.</param> /// <param name="content">Message content to respond with.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <param name="mentions">Allowed mentions in the message</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> RespondWithFilesAsync(Dictionary <string, Stream> files, string content = null, bool tts = false, DiscordEmbed embed = null, IEnumerable <IMention> mentions = null) { if (files.Count > 10) { throw new ArgumentException("Cannot send more than 10 files with a single message."); } return(this.Discord.ApiClient.UploadFilesAsync(this.ChannelId, files, content, tts, embed, mentions)); }
/// <summary> /// Sends a direct message with several files attached to this member. Creates a direct message channel if one does not exist already. /// </summary> /// <param name="files">Dictionary of filename to data stream containing the data to upload as files.</param> /// <param name="content">Content of the message to send.</param> /// <param name="is_tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public async Task <DiscordMessage> SendMultipleFilesAsync(Dictionary <string, Stream> files, string content = null, bool is_tts = false, DiscordEmbed embed = null) { var chn = await this.CreateDmChannelAsync(); return(await chn.SendMultipleFilesAsync(files, content, is_tts, embed)); }
/// <summary> /// Responds to the message. /// </summary> /// <param name="content">Message content to respond with.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public Task <DiscordMessage> RespondAsync(string content = null, bool tts = false, DiscordEmbed embed = null) => this.Discord.ApiClient.CreateMessageAsync(this.ChannelId, content, tts, embed);
/// <summary> /// Sends a message containing an attached file to this channel. /// </summary> /// <param name="file_data">Stream containing the data to attach to the message as a file.</param> /// <param name="content">Content of the message to send.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public Task <DiscordMessage> SendFileAsync(FileStream file_data, string content = null, bool tts = false, DiscordEmbed embed = null) { if (this.Type != ChannelType.Text && this.Type != ChannelType.Private && this.Type != ChannelType.Group) { throw new ArgumentException("Cannot send a file to a non-text channel"); } return(this.Discord.ApiClient.UploadFileAsync(this.Id, file_data, Path.GetFileName(file_data.Name), content, tts, embed)); }
/// <summary> /// Responds to the message with a file. /// </summary> /// <param name="fileData">Stream containing the data to attach to the message as a file.</param> /// <param name="content">Message content to respond with.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public Task <DiscordMessage> RespondWithFileAsync(FileStream fileData, string content = null, bool tts = false, DiscordEmbed embed = null) => this.Discord.ApiClient.UploadFileAsync(this.ChannelId, fileData, Path.GetFileName(fileData.Name), content, tts, embed);
/// <summary> /// Sends a message with several attached files to this channel. /// </summary> /// <param name="files">A filename to data stream mapping.</param> /// <param name="content">Content of the message to send.</param> /// <param name="tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public Task <DiscordMessage> SendMultipleFilesAsync(Dictionary <string, Stream> files, string content = "", bool tts = false, DiscordEmbed embed = null) { if (this.Type != ChannelType.Text && this.Type != ChannelType.Private && this.Type != ChannelType.Group) { throw new ArgumentException("Cannot send a file to a non-text channel"); } return(this.Discord.ApiClient.UploadFilesAsync(Id, files, content, tts, embed)); }
/// <summary> /// Sends a direct message with a file attached to this member. Creates a direct message channel if one does not exist already. /// </summary> /// <param name="fileData">Stream containing the data to attach as a file.</param> /// <param name="fileName">Name of the file to attach.</param> /// <param name="content">Content of the message to send.</param> /// <param name="is_tts">Whether the message is to be read using TTS.</param> /// <param name="embed">Embed to attach to the message.</param> /// <returns>The sent message.</returns> public async Task<DiscordMessage> SendFileAsync(string fileName, Stream fileData, string content = null, bool is_tts = false, DiscordEmbed embed = null) { if (this.IsBot && this.Discord.CurrentUser.IsBot) throw new ArgumentException("Bots cannot DM each other"); var chn = await this.CreateDmChannelAsync().ConfigureAwait(false); return await chn.SendFileAsync(fileName, fileData, content, is_tts, embed).ConfigureAwait(false); }