From afcae02755a16eb83110e7799c3b67bec9694557 Mon Sep 17 00:00:00 2001
From: Still Hsu <341464@gmail.com>
Date: Fri, 31 Aug 2018 16:25:48 +0800
Subject: [PATCH] Add examples in message methods
---
.../Entities/Channels/IMessageChannel.cs | 39 ++++++++++++--
.../Extensions/UserExtensions.cs | 52 ++++++++++++++-----
2 files changed, 73 insertions(+), 18 deletions(-)
diff --git a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
index 5e17617b2..919b3f60b 100644
--- a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
+++ b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
@@ -13,6 +13,15 @@ namespace Discord
///
/// Sends a message to this message channel.
///
+ ///
+ /// The following example sends a message with the current system time in RFC 1123 format to the channel and
+ /// deletes itself after 5 seconds.
+ ///
+ /// var message = await channel.SendMessageAsync(DateTimeOffset.UtcNow.ToString("R"));
+ /// await Task.Delay(TimeSpan.FromSeconds(5))
+ /// .ContinueWith(x => message.DeleteAsync());
+ ///
+ ///
/// The message to be sent.
/// Determines whether the message should be read aloud by Discord or not.
/// The to be sent.
@@ -25,12 +34,26 @@ namespace Discord
///
/// Sends a file to this message channel with an optional caption.
///
+ ///
+ /// The following example uploads a local file called wumpus.txt along with the text
+ /// good discord boi to the channel.
+ ///
+ /// await channel.SendFileAsync("wumpus.txt", "good discord boi");
+ ///
+ ///
+ /// The following example uploads a local image called b1nzy.jpg embedded inside a rich embed to the
+ /// channel.
+ ///
+ /// await channel.SendFileAsync("b1nzy.jpg",
+ /// embed: new EmbedBuilder {ImageUrl = "attachment://b1nzy.jpg"}.Build());
+ ///
+ ///
///
/// This method sends a file as if you are uploading an attachment directly from your Discord client.
///
- /// If you wish to upload an image and have it embedded in a embed,
+ /// If you wish to upload an image and have it embedded in a embed,
/// you may upload the file and refer to the file with "attachment://filename.ext" in the
- /// .
+ /// . See the example section for its usage.
///
///
/// The file path of the file.
@@ -46,12 +69,20 @@ namespace Discord
///
/// Sends a file to this message channel with an optional caption.
///
+ ///
+ /// The following example uploads a streamed image that will be called b1nzy.jpg embedded inside a
+ /// rich embed to the channel.
+ ///
+ /// await channel.SendFileAsync(b1nzyStream, "b1nzy.jpg",
+ /// embed: new EmbedBuilder {ImageUrl = "attachment://b1nzy.jpg"}.Build());
+ ///
+ ///
///
/// This method sends a file as if you are uploading an attachment directly from your Discord client.
///
- /// If you wish to upload an image and have it embedded in a embed,
+ /// If you wish to upload an image and have it embedded in a embed,
/// you may upload the file and refer to the file with "attachment://filename.ext" in the
- /// .
+ /// . See the example section for its usage.
///
///
/// The of the file to be sent.
diff --git a/src/Discord.Net.Core/Extensions/UserExtensions.cs b/src/Discord.Net.Core/Extensions/UserExtensions.cs
index 037e5491b..f98bf7227 100644
--- a/src/Discord.Net.Core/Extensions/UserExtensions.cs
+++ b/src/Discord.Net.Core/Extensions/UserExtensions.cs
@@ -29,7 +29,7 @@ namespace Discord
/// The to be sent.
/// The options to be used when sending the request.
///
- /// A task that represents the asynchrnonous send operation. The task result contains the sent message.
+ /// A task that represents the asynchronous send operation. The task result contains the sent message.
///
public static async Task SendMessageAsync(this IUser user,
string text = null,
@@ -43,6 +43,14 @@ namespace Discord
///
/// Sends a file to this message channel with an optional caption.
///
+ ///
+ /// The following example uploads a streamed image that will be called b1nzy.jpg embedded inside a
+ /// rich embed to the channel.
+ ///
+ /// await channel.SendFileAsync(b1nzyStream, "b1nzy.jpg",
+ /// embed: new EmbedBuilder {ImageUrl = "attachment://b1nzy.jpg"}.Build());
+ ///
+ ///
///
/// This method attempts to send an attachment as a direct-message to the user.
///
@@ -55,6 +63,11 @@ namespace Discord
/// 50007 when using this method.
///
///
+ ///
+ /// If you wish to upload an image and have it embedded in a embed,
+ /// you may upload the file and refer to the file with "attachment://filename.ext" in the
+ /// . See the example section for its usage.
+ ///
///
/// The user to send the DM to.
/// The of the file to be sent.
@@ -63,13 +76,9 @@ namespace Discord
/// Whether the message should be read aloud by Discord or not.
/// The to be sent.
/// The options to be used when sending the request.
- ///
- /// If you wish to upload an image and have it embedded in a embed, you may
- /// upload the file and refer to the file with "attachment://filename.ext" in the
- /// .
- ///
///
- /// A task that represents the asynchrnonous send operation. The task result contains the sent message.
+ /// A task that represents an asynchronous send operation for delivering the message. The task result
+ /// contains the sent message.
///
public static async Task SendFileAsync(this IUser user,
Stream stream,
@@ -86,6 +95,20 @@ namespace Discord
///
/// Sends a file via DM with an optional caption.
///
+ ///
+ /// The following example uploads a local file called wumpus.txt along with the text
+ /// good discord boi to the channel.
+ ///
+ /// await channel.SendFileAsync("wumpus.txt", "good discord boi");
+ ///
+ ///
+ /// The following example uploads a local image called b1nzy.jpg embedded inside a rich embed to the
+ /// channel.
+ ///
+ /// await channel.SendFileAsync("b1nzy.jpg",
+ /// embed: new EmbedBuilder {ImageUrl = "attachment://b1nzy.jpg"}.Build());
+ ///
+ ///
///
/// This method attempts to send an attachment as a direct-message to the user.
///
@@ -98,6 +121,11 @@ namespace Discord
/// 50007 when using this method.
///
///
+ ///
+ /// If you wish to upload an image and have it embedded in a embed,
+ /// you may upload the file and refer to the file with "attachment://filename.ext" in the
+ /// . See the example section for its usage.
+ ///
///
/// The user to send the DM to.
/// The file path of the file.
@@ -105,13 +133,9 @@ namespace Discord
/// Whether the message should be read aloud by Discord or not.
/// The to be sent.
/// The options to be used when sending the request.
- ///
- /// If you wish to upload an image and have it embedded in a embed, you may
- /// upload the file and refer to the file with "attachment://filename.ext" in the
- /// .
- ///
///
- /// A task that represents the asynchrnonous send operation. The task result contains the sent message.
+ /// A task that represents an asynchronous send operation for delivering the message. The task result
+ /// contains the sent message.
///
public static async Task SendFileAsync(this IUser user,
string filePath,
@@ -132,7 +156,7 @@ namespace Discord
/// The options to be used when sending the request.
/// is not between 0 to 7.
///
- /// A task that represents the asynchrnous operation for banning a user.
+ /// A task that represents the asynchronous operation for banning a user.
///
public static Task BanAsync(this IGuildUser user, int pruneDays = 0, string reason = null, RequestOptions options = null)
=> user.Guild.AddBanAsync(user, pruneDays, reason, options);