Class UserExtensions
An extension class for various Discord user objects.
Assembly: Discord.Net.Core.dll​
View Source​
public static class UserExtensions
Methods​
SendMessageAsync(IUser, String, Boolean, Embed, RequestOptions, AllowedMentions, MessageComponent, Embed[])​
Sends a message via DM.
View Source​
public static async Task<IUserMessage> SendMessageAsync(this IUser user, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent component = null, Embed[] embeds = null)
Returns​
System.Threading.Tasks.Task<Discord.IUserMessage>
:
A task that represents the asynchronous send operation. The task result contains the sent message.
Parameters​
Type | Name | Description |
---|---|---|
Discord.IUser | user | The user to send the DM to. |
System.String | text | The message to be sent. |
System.Boolean | isTTS | Whether the message should be read aloud by Discord or not. |
Discord.Embed | embed | The Discord.EmbedType.Rich Discord.Embed to be sent. |
Discord.RequestOptions | options | The options to be used when sending the request. |
Discord.AllowedMentions | allowedMentions |
Specifies if notifications are sent for mentioned users and roles in the message <code data-dev-comment-type="paramref" class="paramref">text</code>.
If null
, all mentioned roles and users will be notified.
|
| Discord.MessageComponent | component | The message components to be included with this message. Used for interactions. |
| Discord.Embed[]
| embeds | A array of Discord.Embeds to send with this response. Max 10. |
SendFileAsync(IUser, Stream, String, String, Boolean, Embed, RequestOptions, MessageComponent, Embed[])​
Sends a file to this message channel with an optional caption.
View Source​
public static async Task<IUserMessage> SendFileAsync(this IUser user, Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, MessageComponent component = null, Embed[] embeds = null)
Returns​
System.Threading.Tasks.Task<Discord.IUserMessage>
:
A task that represents an asynchronous send operation for delivering the message. The task result
contains the sent message.
Parameters​
Type | Name | Description |
---|---|---|
Discord.IUser | user | The user to send the DM to. |
System.IO.Stream | stream | The System.IO.Stream of the file to be sent. |
System.String | filename | The name of the attachment. |
System.String | text | The message to be sent. |
System.Boolean | isTTS | Whether the message should be read aloud by Discord or not. |
Discord.Embed | embed | The Discord.EmbedType.Rich Discord.Embed to be sent. |
Discord.RequestOptions | options | The options to be used when sending the request. |
Discord.MessageComponent | component | The message component to be included with this message. Used for interactions. |
Discord.Embed[] | embeds | A array of Discord.Embeds to send with this response. Max 10. |
SendFileAsync(IUser, String, String, Boolean, Embed, RequestOptions, MessageComponent, Embed[])​
Sends a file via DM with an optional caption.
View Source​
public static async Task<IUserMessage> SendFileAsync(this IUser user, string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, MessageComponent component = null, Embed[] embeds = null)
Returns​
System.Threading.Tasks.Task<Discord.IUserMessage>
:
A task that represents an asynchronous send operation for delivering the message. The task result
contains the sent message.
Parameters​
Type | Name | Description |
---|---|---|
Discord.IUser | user | The user to send the DM to. |
System.String | filePath | The file path of the file. |
System.String | text | The message to be sent. |
System.Boolean | isTTS | Whether the message should be read aloud by Discord or not. |
Discord.Embed | embed | The Discord.EmbedType.Rich Discord.Embed to be sent. |
Discord.RequestOptions | options | The options to be used when sending the request. |
Discord.MessageComponent | component | The message component to be included with this message. Used for interactions. |
Discord.Embed[] | embeds | A array of Discord.Embeds to send with this response. Max 10. |
BanAsync(IGuildUser, Int32, String, RequestOptions)​
Bans the user from the guild and optionally prunes their recent messages.
View Source​
public static Task BanAsync(this IGuildUser user, int pruneDays = 0, string reason = null, RequestOptions options = null)
Returns​
System.Threading.Tasks.Task
:
A task that represents the asynchronous operation for banning a user.
Parameters​
Type | Name | Description |
---|---|---|
Discord.IGuildUser | user | The user to ban. |
System.Int32 | pruneDays | The number of days to remove messages from this <code data-dev-comment-type="paramref" class="paramref">user</code> for - must be between [0, 7] |
System.String | reason | The reason of the ban to be written in the audit log. |
Discord.RequestOptions | options | The options to be used when sending the request. |