@@ -61,6 +61,7 @@ | |||||
"_appFooter": "Discord.Net (c) 2015-2018", | "_appFooter": "Discord.Net (c) 2015-2018", | ||||
"_enableSearch": true | "_enableSearch": true | ||||
}, | }, | ||||
"noLangKeyword": false | |||||
"noLangKeyword": false, | |||||
"xrefService": [ "https://xref.docs.microsoft.com/query?uid={uid}" ] | |||||
} | } | ||||
} | } |
@@ -1,15 +1,15 @@ | |||||
# The Command Service | # The Command Service | ||||
[Discord.Commands](xref:Discord.Commands) provides an Attribute-based | |||||
[Discord.Commands](xref:Discord.Commands) provides an attribute-based | |||||
command parser. | command parser. | ||||
## Setup | ## Setup | ||||
To use Commands, you must create a [Command Service] and a Command | |||||
To use Commands, you must create a [Command Service] and a command | |||||
Handler. | Handler. | ||||
Included below is a very barebone Command Handler. You can extend your | |||||
Command Handler as much as you like; however, the below is the bare | |||||
Included below is a very barebone command handler. You can extend your | |||||
command Handler as much as you like; however, the below is the bare | |||||
minimum. | minimum. | ||||
The `CommandService` will optionally accept a [CommandServiceConfig], | The `CommandService` will optionally accept a [CommandServiceConfig], | ||||
@@ -24,8 +24,8 @@ values. | |||||
## With Attributes | ## With Attributes | ||||
In 1.0, Commands can be defined ahead of time with attributes, or at | |||||
runtime with builders. | |||||
Starting from 1.0, Commands can be defined ahead of time with | |||||
attributes, or at runtime with builders. | |||||
For most bots, ahead-of-time Commands should be all you need, and this | For most bots, ahead-of-time Commands should be all you need, and this | ||||
is the recommended method of defining Commands. | is the recommended method of defining Commands. | ||||
@@ -39,23 +39,24 @@ Commands in different classes and have them automatically loaded. | |||||
Discord.Net's implementation of Modules is influenced heavily from | Discord.Net's implementation of Modules is influenced heavily from | ||||
ASP.NET Core's Controller pattern. This means that the lifetime of a | ASP.NET Core's Controller pattern. This means that the lifetime of a | ||||
module instance is only as long as the Command is being invoked. | |||||
module instance is only as long as the command is being invoked. | |||||
**Avoid using long-running code** in your modules wherever possible. | |||||
You should **not** be implementing very much logic into your modules, | |||||
instead, outsource to a service for that. | |||||
If you are unfamiliar with Inversion of Control, it is recommended to | |||||
read the MSDN article on [IoC] and [Dependency Injection]. | |||||
To begin, create a new class somewhere in your project and inherit the | |||||
class from [ModuleBase]. This class **must** be `public`. | |||||
> [!WARNING] | |||||
> **Avoid using long-running code** in your modules wherever possible. | |||||
> You should **not** be implementing very much logic into your | |||||
> modules, instead, outsource to a service for that. | |||||
> | |||||
> If you are unfamiliar with Inversion of Control, it is recommended | |||||
> to read the MSDN article on [IoC] and [Dependency Injection]. | |||||
>[!NOTE] | >[!NOTE] | ||||
>[ModuleBase] is an _abstract_ class, meaning that you may extend it | >[ModuleBase] is an _abstract_ class, meaning that you may extend it | ||||
>or override it as you see fit. Your module may inherit from any | >or override it as you see fit. Your module may inherit from any | ||||
>extension of ModuleBase. | >extension of ModuleBase. | ||||
To begin, create a new class somewhere in your project and inherit the | |||||
class from [ModuleBase]. This class **must** be `public`. | |||||
By now, your module should look like this: | By now, your module should look like this: | ||||
[!code-csharp[Empty Module](samples/empty-module.cs)] | [!code-csharp[Empty Module](samples/empty-module.cs)] | ||||
@@ -66,36 +67,36 @@ By now, your module should look like this: | |||||
### Adding Commands | ### Adding Commands | ||||
The next step to creating Commands is actually creating the Commands. | |||||
The next step to creating commands is actually creating the commands. | |||||
To create a Command, add a method to your module of type `Task`. | |||||
To create a command, add a method to your module of type `Task` or | |||||
`Task<RuntimeResult>` depending on your use. | |||||
Typically, you will want to mark this method as `async`, although it | Typically, you will want to mark this method as `async`, although it | ||||
is not required. | is not required. | ||||
Adding parameters to a Command is done by adding parameters to the | |||||
parent Task. | |||||
For example, to take an integer as an argument from the user, add `int | |||||
arg`; to take a user as an argument from the user, add `IUser user`. | |||||
In 1.0, a Command can accept nearly any type of argument; a full list | |||||
of types that are parsed by default can be found in the below section | |||||
on _Type Readers_. | |||||
Adding parameters to a command is done by adding parameters to the | |||||
parent Task. For example, to take an integer as an argument from | |||||
the user, add `int arg`; to take a user as an argument from the | |||||
user, add `IUser user`. Starting from 1.0, a command can accept | |||||
nearly any type of argument; a full list of types that are parsed | |||||
by default can be found in the below | |||||
section on [Type Readers](#type-readers). | |||||
Parameters, by default, are always required. To make a parameter | Parameters, by default, are always required. To make a parameter | ||||
optional, give it a default value. To accept a comma-separated list, | optional, give it a default value. To accept a comma-separated list, | ||||
set the parameter to `params Type[]`. | set the parameter to `params Type[]`. | ||||
Should a parameter include spaces, it **must** be wrapped in quotes. | |||||
For example, for a Command with a parameter `string food`, you would | |||||
execute it with `!favoritefood "Key Lime Pie"`. | |||||
If you would like a parameter to parse until the end of a Command, | |||||
flag the parameter with the [RemainderAttribute]. This will allow a | |||||
user to invoke a Command without wrapping a parameter in quotes. | |||||
Should a parameter include spaces, the parameter **must** be | |||||
wrapped in quotes. For example, for a command with a parameter | |||||
`string food`, you would execute it with | |||||
`!favoritefood "Key Lime Pie"`. If you would like a parameter to | |||||
parse until the end of a command, flag the parameter with the | |||||
[RemainderAttribute]. This will allow a user to invoke a command | |||||
without wrapping a parameter in quotes. | |||||
Finally, flag your Command with the [CommandAttribute]. (you must | |||||
specify a name for this Command, except for when it is part of a | |||||
Module Group - see below) | |||||
Finally, flag your command with the [CommandAttribute] (you must | |||||
specify a name for this command, except for when it is part of a | |||||
[Module Group](#module-groups). | |||||
[RemainderAttribute]: xref:Discord.Commands.RemainderAttribute | [RemainderAttribute]: xref:Discord.Commands.RemainderAttribute | ||||
[CommandAttribute]: xref:Discord.Commands.CommandAttribute | [CommandAttribute]: xref:Discord.Commands.CommandAttribute | ||||
@@ -114,11 +115,10 @@ priority will be called first. | |||||
### Command Context | ### Command Context | ||||
Every Command can access the execution context through the [Context] | |||||
Every command can access the execution context through the [Context] | |||||
property on [ModuleBase]. `ICommandContext` allows you to access the | property on [ModuleBase]. `ICommandContext` allows you to access the | ||||
message, channel, guild, and user that the Command was invoked from, | |||||
as well as the underlying Discord client that the Command was invoked | |||||
from. | |||||
message, channel, guild, user, and the underlying Discord client | |||||
that the command was invoked from. | |||||
Different types of Contexts may be specified using the generic variant | Different types of Contexts may be specified using the generic variant | ||||
of [ModuleBase]. When using a [SocketCommandContext], for example, the | of [ModuleBase]. When using a [SocketCommandContext], for example, the | ||||
@@ -132,7 +132,7 @@ accessing the channel through the [Context] and sending a message. | |||||
>Contexts should **NOT** be mixed! You cannot have one module that | >Contexts should **NOT** be mixed! You cannot have one module that | ||||
>uses `CommandContext` and another that uses `SocketCommandContext`. | >uses `CommandContext` and another that uses `SocketCommandContext`. | ||||
[Context]: xref:Discord.Commands.ModuleBase`1#Discord_Commands_ModuleBase_1_Context | |||||
[Context]: xref:Discord.Commands.ModuleBase`1.Context | |||||
[SocketCommandContext]: xref:Discord.Commands.SocketCommandContext | [SocketCommandContext]: xref:Discord.Commands.SocketCommandContext | ||||
[ReplyAsync]: xref:Discord.Commands.ModuleBase`1.ReplyAsync* | [ReplyAsync]: xref:Discord.Commands.ModuleBase`1.ReplyAsync* | ||||
@@ -144,14 +144,13 @@ At this point, your module should look comparable to this example: | |||||
#### Loading Modules Automatically | #### Loading Modules Automatically | ||||
The Command Service can automatically discover all classes in an | The Command Service can automatically discover all classes in an | ||||
Assembly that inherit [ModuleBase] and load them. | |||||
Assembly that inherit [ModuleBase] and load them. Invoke | |||||
[CommandService.AddModulesAsync] to discover modules and | |||||
install them. | |||||
To opt a module out of auto-loading, flag it with | To opt a module out of auto-loading, flag it with | ||||
[DontAutoLoadAttribute]. | [DontAutoLoadAttribute]. | ||||
Invoke [CommandService.AddModulesAsync] to discover modules and | |||||
install them. | |||||
[DontAutoLoadAttribute]: xref:Discord.Commands.DontAutoLoadAttribute | [DontAutoLoadAttribute]: xref:Discord.Commands.DontAutoLoadAttribute | ||||
[CommandService.AddModulesAsync]: xref:Discord.Commands.CommandService.AddModulesAsync* | [CommandService.AddModulesAsync]: xref:Discord.Commands.CommandService.AddModulesAsync* | ||||
@@ -187,7 +186,7 @@ prefixed. To create a group, flag a module with the | |||||
Module groups also allow you to create **nameless Commands**, where | Module groups also allow you to create **nameless Commands**, where | ||||
the [CommandAttribute] is configured with no name. In this case, the | the [CommandAttribute] is configured with no name. In this case, the | ||||
Command will inherit the name of the group it belongs to. | |||||
command will inherit the name of the group it belongs to. | |||||
### Submodules | ### Submodules | ||||
@@ -209,20 +208,19 @@ DI when writing your modules. | |||||
### Setup | ### Setup | ||||
First, you need to create an @System.IServiceProvider; you may create | |||||
your own one if you wish. | |||||
First, you need to create an @System.IServiceProvider. | |||||
Next, add the dependencies that your modules will use to the map. | |||||
Next, add the dependencies to the service collection that you wish | |||||
to use in the Modules. | |||||
Finally, pass the map into the `LoadAssembly` method. Your modules | |||||
will be automatically loaded with this dependency map. | |||||
Finally, pass the service collection into `AddModulesAsync`. | |||||
[!code-csharp[IServiceProvider Setup](samples/dependency_map_setup.cs)] | [!code-csharp[IServiceProvider Setup](samples/dependency_map_setup.cs)] | ||||
### Usage in Modules | ### Usage in Modules | ||||
In the constructor of your Module, any parameters will be filled in by | In the constructor of your Module, any parameters will be filled in by | ||||
the @System.IServiceProvider that you've passed into `LoadAssembly`. | |||||
the @System.IServiceProvider that you've passed. | |||||
Any publicly settable properties will also be filled in the same | Any publicly settable properties will also be filled in the same | ||||
manner. | manner. | ||||
@@ -264,6 +262,7 @@ usages on their respective API pages. | |||||
- @Discord.Commands.RequireOwnerAttribute | - @Discord.Commands.RequireOwnerAttribute | ||||
- @Discord.Commands.RequireBotPermissionAttribute | - @Discord.Commands.RequireBotPermissionAttribute | ||||
- @Discord.Commands.RequireUserPermissionAttribute | - @Discord.Commands.RequireUserPermissionAttribute | ||||
- @Discord.Commands.RequireNsfwAttribute | |||||
## Custom Preconditions | ## Custom Preconditions | ||||
@@ -40,7 +40,7 @@ public class Program | |||||
// Hook the MessageReceived Event into our Command Handler | // Hook the MessageReceived Event into our Command Handler | ||||
_client.MessageReceived += HandleCommandAsync; | _client.MessageReceived += HandleCommandAsync; | ||||
// Discover all of the commands in this assembly and load them. | // Discover all of the commands in this assembly and load them. | ||||
await _commands.AddModulesAsync(Assembly.GetEntryAssembly()); | |||||
await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _services); | |||||
} | } | ||||
private async Task HandleCommandAsync(SocketMessage messageParam) | private async Task HandleCommandAsync(SocketMessage messageParam) | ||||
@@ -14,5 +14,5 @@ public async Task InstallAsync(DiscordSocketClient client) | |||||
.AddSingleton<DatabaseService>() | .AddSingleton<DatabaseService>() | ||||
.BuildServiceProvider(); | .BuildServiceProvider(); | ||||
// ... | // ... | ||||
await _commands.AddModulesAsync(Assembly.GetEntryAssembly()); | |||||
await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _services); | |||||
} | } |
@@ -2,7 +2,7 @@ using Discord; | |||||
using Discord.Commands; | using Discord.Commands; | ||||
using Discord.WebSocket; | using Discord.WebSocket; | ||||
public class ModuleA : ModuleBase | |||||
public class ModuleA : ModuleBase<SocketCommandContext> | |||||
{ | { | ||||
private readonly DatabaseService _database; | private readonly DatabaseService _database; | ||||
@@ -19,11 +19,11 @@ public class ModuleA : ModuleBase | |||||
} | } | ||||
} | } | ||||
public class ModuleB | |||||
public class ModuleB : ModuleBase<SocketCommandContext> | |||||
{ | { | ||||
// Public settable properties will be injected | // Public settable properties will be injected | ||||
public AnnounceService { get; set; } | |||||
public AnnounceService Announce { get; set; } | |||||
// Public properties without setters will not | // Public properties without setters will not | ||||
public CommandService Commands { get; } | public CommandService Commands { get; } | ||||
@@ -1,14 +1,13 @@ | |||||
// Create a module with no prefix | // Create a module with no prefix | ||||
public class Info : ModuleBase<SocketCommandContext> | public class Info : ModuleBase<SocketCommandContext> | ||||
{ | { | ||||
// ~say hello -> hello | |||||
// ~say hello world -> hello world | |||||
[Command("say")] | [Command("say")] | ||||
[Summary("Echoes a message.")] | [Summary("Echoes a message.")] | ||||
public async Task SayAsync([Remainder] [Summary("The text to echo")] string echo) | |||||
{ | |||||
// ReplyAsync is a method on ModuleBase | |||||
await ReplyAsync(echo); | |||||
} | |||||
public Task SayAsync([Remainder] [Summary("The text to echo")] string echo) | |||||
=> ReplyAsync(echo); | |||||
// ReplyAsync is a method on ModuleBase | |||||
} | } | ||||
// Create a module with the 'sample' prefix | // Create a module with the 'sample' prefix | ||||
@@ -18,7 +17,9 @@ public class Sample : ModuleBase<SocketCommandContext> | |||||
// ~sample square 20 -> 400 | // ~sample square 20 -> 400 | ||||
[Command("square")] | [Command("square")] | ||||
[Summary("Squares a number.")] | [Summary("Squares a number.")] | ||||
public async Task SquareAsync([Summary("The number to square.")] int num) | |||||
public async Task SquareAsync( | |||||
[Summary("The number to square.")] | |||||
int num) | |||||
{ | { | ||||
// We can also access the channel from the Command Context. | // We can also access the channel from the Command Context. | ||||
await Context.Channel.SendMessageAsync($"{num}^2 = {Math.Pow(num, 2)}"); | await Context.Channel.SendMessageAsync($"{num}^2 = {Math.Pow(num, 2)}"); | ||||
@@ -31,9 +32,12 @@ public class Sample : ModuleBase<SocketCommandContext> | |||||
// ~sample userinfo 96642168176807936 --> Khionu#8708 | // ~sample userinfo 96642168176807936 --> Khionu#8708 | ||||
// ~sample whois 96642168176807936 --> Khionu#8708 | // ~sample whois 96642168176807936 --> Khionu#8708 | ||||
[Command("userinfo")] | [Command("userinfo")] | ||||
[Summary("Returns info about the current user, or the user parameter, if one passed.")] | |||||
[Summary | |||||
("Returns info about the current user, or the user parameter, if one passed.")] | |||||
[Alias("user", "whois")] | [Alias("user", "whois")] | ||||
public async Task UserInfoAsync([Summary("The (optional) user to get info for")] SocketUser user = null) | |||||
public async Task UserInfoAsync( | |||||
[Summary("The (optional) user to get info for")] | |||||
SocketUser user = null) | |||||
{ | { | ||||
var userInfo = user ?? Context.Client.CurrentUser; | var userInfo = user ?? Context.Client.CurrentUser; | ||||
await ReplyAsync($"{userInfo.Username}#{userInfo.Discriminator}"); | await ReplyAsync($"{userInfo.Username}#{userInfo.Discriminator}"); | ||||
@@ -10,7 +10,7 @@ using System.Threading.Tasks; | |||||
public class RequireOwnerAttribute : PreconditionAttribute | public class RequireOwnerAttribute : PreconditionAttribute | ||||
{ | { | ||||
// Override the CheckPermissions method | // Override the CheckPermissions method | ||||
public async override Task<PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IServiceProvider services) | |||||
public async override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) | |||||
{ | { | ||||
// Get the ID of the bot's owner | // Get the ID of the bot's owner | ||||
var ownerId = (await services.GetService<DiscordSocketClient>().GetApplicationInfoAsync()).Owner.Id; | var ownerId = (await services.GetService<DiscordSocketClient>().GetApplicationInfoAsync()).Owner.Id; | ||||
@@ -4,7 +4,7 @@ using Discord.Commands; | |||||
public class BooleanTypeReader : TypeReader | public class BooleanTypeReader : TypeReader | ||||
{ | { | ||||
public override Task<TypeReaderResult> Read(ICommandContext context, string input, IServiceProvider services) | |||||
public override Task<TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider services) | |||||
{ | { | ||||
bool result; | bool result; | ||||
if (bool.TryParse(input, out result)) | if (bool.TryParse(input, out result)) | ||||
@@ -7,7 +7,7 @@ namespace Discord.Commands | |||||
public class CommandAttribute : Attribute | public class CommandAttribute : Attribute | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Specifies the text required to be recognized as a command. | |||||
/// Gets the text that has been set to be recognized as a command. | |||||
/// </summary> | /// </summary> | ||||
public string Text { get; } | public string Text { get; } | ||||
/// <summary> | /// <summary> | ||||
@@ -2,6 +2,7 @@ using System; | |||||
namespace Discord.Commands | namespace Discord.Commands | ||||
{ | { | ||||
/// <summary> Prevents the module from being loaded automatically. </summary> | |||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] | ||||
public class DontAutoLoadAttribute : Attribute | public class DontAutoLoadAttribute : Attribute | ||||
{ | { | ||||
@@ -2,6 +2,7 @@ using System; | |||||
namespace Discord.Commands { | namespace Discord.Commands { | ||||
/// <summary> Prevents the property from being injected into a module. </summary> | |||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] | [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] | ||||
public class DontInjectAttribute : Attribute { | public class DontInjectAttribute : Attribute { | ||||
} | } | ||||
@@ -4,7 +4,7 @@ using System.Threading.Tasks; | |||||
namespace Discord.Commands | namespace Discord.Commands | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// This attribute requires the bot to have a specific permission in the channel a command is invoked in. | |||||
/// Requires the bot to have a specific permission in the channel a command is invoked in. | |||||
/// </summary> | /// </summary> | ||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | ||||
public class RequireBotPermissionAttribute : PreconditionAttribute | public class RequireBotPermissionAttribute : PreconditionAttribute | ||||
@@ -13,7 +13,7 @@ namespace Discord.Commands | |||||
public ChannelPermission? ChannelPermission { get; } | public ChannelPermission? ChannelPermission { get; } | ||||
/// <summary> | /// <summary> | ||||
/// Requires that the bot account to have a specific <see cref="GuildPermission"/>. | |||||
/// Requires the bot account to have a specific <see cref="GuildPermission"/>. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks>This precondition will always fail if the command is being invoked in a private channel.</remarks> | /// <remarks>This precondition will always fail if the command is being invoked in a private channel.</remarks> | ||||
/// <param name="permission">The GuildPermission that the bot must have. Multiple permissions can be specified by ORing the permissions together.</param> | /// <param name="permission">The GuildPermission that the bot must have. Multiple permissions can be specified by ORing the permissions together.</param> | ||||
@@ -13,7 +13,7 @@ namespace Discord.Commands | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// This attribute requires that the command be invoked in a specified context. (e.g. in guild, DM) | |||||
/// Requires the command to be invoked in a specified context. (e.g. in guild, DM) | |||||
/// </summary> | /// </summary> | ||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | ||||
public class RequireContextAttribute : PreconditionAttribute | public class RequireContextAttribute : PreconditionAttribute | ||||
@@ -4,7 +4,7 @@ using System.Threading.Tasks; | |||||
namespace Discord.Commands | namespace Discord.Commands | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// This attribute requires that the command to be invoked in a channel marked NSFW. | |||||
/// Requires the command to be invoked in a channel marked NSFW. | |||||
/// </summary> | /// </summary> | ||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | ||||
public class RequireNsfwAttribute : PreconditionAttribute | public class RequireNsfwAttribute : PreconditionAttribute | ||||
@@ -4,7 +4,7 @@ using System.Threading.Tasks; | |||||
namespace Discord.Commands | namespace Discord.Commands | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// This attribute requires that the command to be invoked by the owner of the bot. | |||||
/// Requires the command to be invoked by the owner of the bot. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks>This precondition will only work if the bot is a bot account.</remarks> | /// <remarks>This precondition will only work if the bot is a bot account.</remarks> | ||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | ||||
@@ -4,7 +4,7 @@ using System.Threading.Tasks; | |||||
namespace Discord.Commands | namespace Discord.Commands | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// This attribute requires that the user invoking the command has a specified permission. | |||||
/// Requires the user invoking the command to have a specified permission. | |||||
/// </summary> | /// </summary> | ||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | ||||
public class RequireUserPermissionAttribute : PreconditionAttribute | public class RequireUserPermissionAttribute : PreconditionAttribute | ||||
@@ -2,11 +2,11 @@ using System; | |||||
namespace Discord.Commands | namespace Discord.Commands | ||||
{ | { | ||||
/// <summary> Sets priority of commands </summary> | |||||
/// <summary> Sets priority of commands. </summary> | |||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] | ||||
public class PriorityAttribute : Attribute | public class PriorityAttribute : Attribute | ||||
{ | { | ||||
/// <summary> The priority which has been set for the command </summary> | |||||
/// <summary> Gets the priority which has been set for the command. </summary> | |||||
public int Priority { get; } | public int Priority { get; } | ||||
/// <summary> Creates a new <see cref="PriorityAttribute"/> with the given priority. </summary> | /// <summary> Creates a new <see cref="PriorityAttribute"/> with the given priority. </summary> | ||||
@@ -1,10 +1,15 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Specifies the connection state of a client. </summary> | |||||
public enum ConnectionState : byte | public enum ConnectionState : byte | ||||
{ | { | ||||
/// <summary> Represents that the client has disconnected from the WebSocket. </summary> | |||||
Disconnected, | Disconnected, | ||||
/// <summary> Represents that the client is connecting to the WebSocket. </summary> | |||||
Connecting, | Connecting, | ||||
/// <summary> Represents that the client has established a connection to the WebSocket. </summary> | |||||
Connected, | Connected, | ||||
/// <summary> Represents that the client is disconnecting from the WebSocket. </summary> | |||||
Disconnecting | Disconnecting | ||||
} | } | ||||
} | } |
@@ -1,17 +1,15 @@ | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> | |||||
/// Defines user's activity type. | |||||
/// </summary> | |||||
/// <summary> Specifies a Discord user's activity type. </summary> | |||||
public enum ActivityType | public enum ActivityType | ||||
{ | { | ||||
/// <summary> Activity that represents a user that is playing a game. </summary> | |||||
/// <summary> Represents that the user is playing a game. </summary> | |||||
Playing = 0, | Playing = 0, | ||||
/// <summary> Activity that represents a user that is streaming online. </summary> | |||||
/// <summary> Represents that the user is streaming online. </summary> | |||||
Streaming = 1, | Streaming = 1, | ||||
/// <summary> Activity that represents a user that is listening to a song. </summary> | |||||
/// <summary> Represents that the user is listening to a song. </summary> | |||||
Listening = 2, | Listening = 2, | ||||
/// <summary> Activity that represents a user that is watching a media. </summary> | |||||
/// <summary> Represents that the user is watching a media. </summary> | |||||
Watching = 3 | Watching = 3 | ||||
} | } | ||||
} | } |
@@ -2,10 +2,13 @@ using System.Diagnostics; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> A user's game activity. </summary> | |||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
public class Game : IActivity | public class Game : IActivity | ||||
{ | { | ||||
/// <inheritdoc/> | |||||
public string Name { get; internal set; } | public string Name { get; internal set; } | ||||
/// <inheritdoc/> | |||||
public ActivityType Type { get; internal set; } | public ActivityType Type { get; internal set; } | ||||
internal Game() { } | internal Game() { } | ||||
@@ -1,6 +1,6 @@ | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> The asset for a <see cref="RichGame"/> object. </summary> | |||||
/// <summary> An asset for a <see cref="RichGame"/> object. </summary> | |||||
public class GameAsset | public class GameAsset | ||||
{ | { | ||||
internal GameAsset() { } | internal GameAsset() { } | ||||
@@ -2,7 +2,7 @@ using System; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> The timestamps for a <see cref="RichGame"/> object. </summary> | |||||
/// <summary> Timestamps for a <see cref="RichGame"/> object. </summary> | |||||
public class GameTimestamps | public class GameTimestamps | ||||
{ | { | ||||
public DateTimeOffset? Start { get; } | public DateTimeOffset? Start { get; } | ||||
@@ -1,8 +1,11 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> A Discord activity. </summary> | |||||
public interface IActivity | public interface IActivity | ||||
{ | { | ||||
/// <summary> Gets the name of the activity. </summary> | |||||
string Name { get; } | string Name { get; } | ||||
/// <summary> Gets the type of the activity. </summary> | |||||
ActivityType Type { get; } | ActivityType Type { get; } | ||||
} | } | ||||
} | } |
@@ -4,19 +4,28 @@ using System.Diagnostics; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> A user's activity for listening to a song on Spotify. </summary> | |||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
public class SpotifyGame : Game | public class SpotifyGame : Game | ||||
{ | { | ||||
/// <summary> Gets the song's artist(s). </summary> | |||||
public IEnumerable<string> Artists { get; internal set; } | public IEnumerable<string> Artists { get; internal set; } | ||||
/// <summary> Gets the Spotify album art for the song. </summary> | |||||
public string AlbumArt { get; internal set; } | public string AlbumArt { get; internal set; } | ||||
/// <summary> Gets the Spotify album title for the song. </summary> | |||||
public string AlbumTitle { get; internal set; } | public string AlbumTitle { get; internal set; } | ||||
/// <summary> Gets the track title for the song. </summary> | |||||
public string TrackTitle { get; internal set; } | public string TrackTitle { get; internal set; } | ||||
/// <summary> Gets the synchronization ID for the song. </summary> | |||||
public string SyncId { get; internal set; } | public string SyncId { get; internal set; } | ||||
/// <summary> Gets the session ID for the song. </summary> | |||||
public string SessionId { get; internal set; } | public string SessionId { get; internal set; } | ||||
/// <summary> Gets the duration for the song. </summary> | |||||
public TimeSpan? Duration { get; internal set; } | public TimeSpan? Duration { get; internal set; } | ||||
internal SpotifyGame() { } | internal SpotifyGame() { } | ||||
/// <summary> Gets the name of the song. </summary> | |||||
public override string ToString() => Name; | public override string ToString() => Name; | ||||
private string DebuggerDisplay => $"{Name} (Spotify)"; | private string DebuggerDisplay => $"{Name} (Spotify)"; | ||||
} | } | ||||
@@ -1,10 +1,12 @@ | |||||
using System.Diagnostics; | |||||
using System.Diagnostics; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> A user's activity for streaming on services such as Twitch. </summary> | |||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
public class StreamingGame : Game | public class StreamingGame : Game | ||||
{ | { | ||||
/// <summary> Gets the URL of the stream. </summary> | |||||
public string Url { get; internal set; } | public string Url { get; internal set; } | ||||
public StreamingGame(string name, string url) | public StreamingGame(string name, string url) | ||||
@@ -14,7 +16,8 @@ namespace Discord | |||||
Type = ActivityType.Streaming; | Type = ActivityType.Streaming; | ||||
} | } | ||||
/// <summary> Gets the name of the stream. </summary> | |||||
public override string ToString() => Name; | public override string ToString() => Name; | ||||
private string DebuggerDisplay => $"{Name} ({Url})"; | private string DebuggerDisplay => $"{Name} ({Url})"; | ||||
} | } | ||||
} | |||||
} |
@@ -1,5 +1,6 @@ | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Specifies the cache mode that should be used. </summary> | |||||
public enum CacheMode | public enum CacheMode | ||||
{ | { | ||||
/// <summary> Allows the object to be downloaded if it does not exist in the current cache. </summary> | /// <summary> Allows the object to be downloaded if it does not exist in the current cache. </summary> | ||||
@@ -1,9 +1,13 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Specifies the direction of where message(s) should be gotten from. </summary> | |||||
public enum Direction | public enum Direction | ||||
{ | { | ||||
/// <summary> The message(s) should be retrieved before a message. </summary> | |||||
Before, | Before, | ||||
/// <summary> The message(s) should be retrieved after a message. </summary> | |||||
After, | After, | ||||
/// <summary> The message(s) should be retrieved around a message. </summary> | |||||
Around | Around | ||||
} | } | ||||
} | } |
@@ -1,5 +1,6 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Specifies the default message notification behavior the guild uses. </summary> | |||||
public enum DefaultMessageNotifications | public enum DefaultMessageNotifications | ||||
{ | { | ||||
/// <summary> By default, all messages will trigger notifications. </summary> | /// <summary> By default, all messages will trigger notifications. </summary> | ||||
@@ -1,7 +1,7 @@ | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Properties that are used to modify the widget of an <see cref="IGuild"/> with the specified parameters. | |||||
/// Properties that are used to modify the widget of an <see cref="IGuild"/> with the specified changes. | |||||
/// </summary> | /// </summary> | ||||
public class GuildEmbedProperties | public class GuildEmbedProperties | ||||
{ | { | ||||
@@ -1,9 +1,13 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Properties used to modify an <see cref="IGuildIntegration"/> with the specified changes.</summary> | |||||
public class GuildIntegrationProperties | public class GuildIntegrationProperties | ||||
{ | { | ||||
/// <summary> Gets or sets the behavior when an integration subscription lapses. </summary> | |||||
public Optional<int> ExpireBehavior { get; set; } | public Optional<int> ExpireBehavior { get; set; } | ||||
/// <summary> Gets or sets the period (in seconds) where the integration will ignore lapsed subscriptions. </summary> | |||||
public Optional<int> ExpireGracePeriod { get; set; } | public Optional<int> ExpireGracePeriod { get; set; } | ||||
/// <summary> Gets or sets whether emoticons should be synced for this integration. </summary> | |||||
public Optional<bool> EnableEmoticons { get; set; } | public Optional<bool> EnableEmoticons { get; set; } | ||||
} | } | ||||
} | } |
@@ -1,5 +1,6 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Specifies the guild's Multi-Factor Authentication (MFA) level requirement. </summary> | |||||
public enum MfaLevel | public enum MfaLevel | ||||
{ | { | ||||
/// <summary> Users have no additional MFA restriction on this guild. </summary> | /// <summary> Users have no additional MFA restriction on this guild. </summary> | ||||
@@ -1,8 +1,11 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Specifies the target of the permission. </summary> | |||||
public enum PermissionTarget | public enum PermissionTarget | ||||
{ | { | ||||
/// <summary> The target of the permission is a role. </summary> | |||||
Role, | Role, | ||||
/// <summary> The target of the permission is a user. </summary> | |||||
User | User | ||||
} | } | ||||
} | } |
@@ -1,5 +1,6 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Specifies the verification level the guild uses. </summary> | |||||
public enum VerificationLevel | public enum VerificationLevel | ||||
{ | { | ||||
/// <summary> Users have no additional restrictions on sending messages to this guild. </summary> | /// <summary> Users have no additional restrictions on sending messages to this guild. </summary> | ||||
@@ -1,7 +1,8 @@ | |||||
using System.Threading.Tasks; | |||||
using System.Threading.Tasks; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Represents whether the object is deletable or not. </summary> | |||||
public interface IDeletable | public interface IDeletable | ||||
{ | { | ||||
/// <summary> Deletes this object and all its children. </summary> | /// <summary> Deletes this object and all its children. </summary> | ||||
@@ -1,5 +1,6 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Represents whether the object is mentionable or not. </summary> | |||||
public interface IMentionable | public interface IMentionable | ||||
{ | { | ||||
/// <summary> Returns a special string used to mention this object. </summary> | /// <summary> Returns a special string used to mention this object. </summary> | ||||
@@ -2,6 +2,7 @@ using System; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Represents a Discord snowflake entity. </summary> | |||||
public interface ISnowflakeEntity : IEntity<ulong> | public interface ISnowflakeEntity : IEntity<ulong> | ||||
{ | { | ||||
DateTimeOffset CreatedAt { get; } | DateTimeOffset CreatedAt { get; } | ||||
@@ -1,7 +1,8 @@ | |||||
using System.Threading.Tasks; | |||||
using System.Threading.Tasks; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Represents whether the object is updatable or not. </summary> | |||||
public interface IUpdateable | public interface IUpdateable | ||||
{ | { | ||||
/// <summary> Updates this object's properties with its current state. </summary> | /// <summary> Updates this object's properties with its current state. </summary> | ||||
@@ -1,6 +1,6 @@ | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> The type of format for the image to return. </summary> | |||||
/// <summary> Specifies the type of format the image should return in. </summary> | |||||
public enum ImageFormat | public enum ImageFormat | ||||
{ | { | ||||
Auto, | Auto, | ||||
@@ -1,4 +1,4 @@ | |||||
using System; | |||||
using System; | |||||
using System.Collections.Immutable; | using System.Collections.Immutable; | ||||
using System.Diagnostics; | using System.Diagnostics; | ||||
using System.Linq; | using System.Linq; | ||||
@@ -8,19 +8,32 @@ namespace Discord | |||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
public class Embed : IEmbed | public class Embed : IEmbed | ||||
{ | { | ||||
/// <inheritdoc/> | |||||
public EmbedType Type { get; } | public EmbedType Type { get; } | ||||
/// <inheritdoc/> | |||||
public string Description { get; internal set; } | public string Description { get; internal set; } | ||||
/// <inheritdoc/> | |||||
public string Url { get; internal set; } | public string Url { get; internal set; } | ||||
/// <inheritdoc/> | |||||
public string Title { get; internal set; } | public string Title { get; internal set; } | ||||
/// <inheritdoc/> | |||||
public DateTimeOffset? Timestamp { get; internal set; } | public DateTimeOffset? Timestamp { get; internal set; } | ||||
/// <inheritdoc/> | |||||
public Color? Color { get; internal set; } | public Color? Color { get; internal set; } | ||||
/// <inheritdoc/> | |||||
public EmbedImage? Image { get; internal set; } | public EmbedImage? Image { get; internal set; } | ||||
/// <inheritdoc/> | |||||
public EmbedVideo? Video { get; internal set; } | public EmbedVideo? Video { get; internal set; } | ||||
/// <inheritdoc/> | |||||
public EmbedAuthor? Author { get; internal set; } | public EmbedAuthor? Author { get; internal set; } | ||||
/// <inheritdoc/> | |||||
public EmbedFooter? Footer { get; internal set; } | public EmbedFooter? Footer { get; internal set; } | ||||
/// <inheritdoc/> | |||||
public EmbedProvider? Provider { get; internal set; } | public EmbedProvider? Provider { get; internal set; } | ||||
/// <inheritdoc/> | |||||
public EmbedThumbnail? Thumbnail { get; internal set; } | public EmbedThumbnail? Thumbnail { get; internal set; } | ||||
/// <inheritdoc/> | |||||
public ImmutableArray<EmbedField> Fields { get; internal set; } | public ImmutableArray<EmbedField> Fields { get; internal set; } | ||||
internal Embed(EmbedType type) | internal Embed(EmbedType type) | ||||
@@ -1,14 +1,19 @@ | |||||
using System; | |||||
using System; | |||||
using System.Diagnostics; | using System.Diagnostics; | ||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> An author field for an <see cref="Embed"/>. </summary> | |||||
[DebuggerDisplay("{DebuggerDisplay,nq}")] | [DebuggerDisplay("{DebuggerDisplay,nq}")] | ||||
public struct EmbedAuthor | public struct EmbedAuthor | ||||
{ | { | ||||
/// <summary> Gets the name of the author field.</summary> | |||||
public string Name { get; internal set; } | public string Name { get; internal set; } | ||||
/// <summary> Gets the URL of the author field.</summary> | |||||
public string Url { get; internal set; } | public string Url { get; internal set; } | ||||
/// <summary> Gets the icon URL of the author field.</summary> | |||||
public string IconUrl { get; internal set; } | public string IconUrl { get; internal set; } | ||||
/// <summary> Gets the proxified icon URL of the author field.</summary> | |||||
public string ProxyIconUrl { get; internal set; } | public string ProxyIconUrl { get; internal set; } | ||||
internal EmbedAuthor(string name, string url, string iconUrl, string proxyIconUrl) | internal EmbedAuthor(string name, string url, string iconUrl, string proxyIconUrl) | ||||
@@ -1,12 +1,10 @@ | |||||
using System; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Collections.Immutable; | using System.Collections.Immutable; | ||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> | |||||
/// Builder for creating an <see cref="Embed"/> to be sent. | |||||
/// </summary> | |||||
/// <summary> A builder for creating an <see cref="Embed"/> to be sent. </summary> | |||||
public class EmbedBuilder | public class EmbedBuilder | ||||
{ | { | ||||
private readonly Embed _embed; | private readonly Embed _embed; | ||||
@@ -1,12 +1,16 @@ | |||||
using System.Diagnostics; | |||||
using System.Diagnostics; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> A field for an <see cref="Embed"/>. </summary> | |||||
[DebuggerDisplay("{DebuggerDisplay,nq}")] | [DebuggerDisplay("{DebuggerDisplay,nq}")] | ||||
public struct EmbedField | public struct EmbedField | ||||
{ | { | ||||
/// <summary> Gets the name of the field.</summary> | |||||
public string Name { get; internal set; } | public string Name { get; internal set; } | ||||
/// <summary> Gets the value of the field.</summary> | |||||
public string Value { get; internal set; } | public string Value { get; internal set; } | ||||
/// <summary> Gets whether the field is inline inside an <see cref="Embed"/> or not.</summary> | |||||
public bool Inline { get; internal set; } | public bool Inline { get; internal set; } | ||||
internal EmbedField(string name, string value, bool inline) | internal EmbedField(string name, string value, bool inline) | ||||
@@ -1,13 +1,17 @@ | |||||
using System; | |||||
using System; | |||||
using System.Diagnostics; | using System.Diagnostics; | ||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> A footer field for an <see cref="Embed"/>. </summary> | |||||
[DebuggerDisplay("{DebuggerDisplay,nq}")] | [DebuggerDisplay("{DebuggerDisplay,nq}")] | ||||
public struct EmbedFooter | public struct EmbedFooter | ||||
{ | { | ||||
/// <summary> Gets the text of the footer.</summary> | |||||
public string Text { get; internal set; } | public string Text { get; internal set; } | ||||
/// <summary> Gets the icon URL of the footer.</summary> | |||||
public string IconUrl { get; internal set; } | public string IconUrl { get; internal set; } | ||||
/// <summary> Gets the proxified icon URL of the footer.</summary> | |||||
public string ProxyUrl { get; internal set; } | public string ProxyUrl { get; internal set; } | ||||
internal EmbedFooter(string text, string iconUrl, string proxyUrl) | internal EmbedFooter(string text, string iconUrl, string proxyUrl) | ||||
@@ -1,14 +1,19 @@ | |||||
using System; | |||||
using System; | |||||
using System.Diagnostics; | using System.Diagnostics; | ||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> An image for an <see cref="Embed"/>. </summary> | |||||
[DebuggerDisplay("{DebuggerDisplay,nq}")] | [DebuggerDisplay("{DebuggerDisplay,nq}")] | ||||
public struct EmbedImage | public struct EmbedImage | ||||
{ | { | ||||
/// <summary> Gets the URL of the image.</summary> | |||||
public string Url { get; } | public string Url { get; } | ||||
/// <summary> Gets the proxified URL of the image.</summary> | |||||
public string ProxyUrl { get; } | public string ProxyUrl { get; } | ||||
/// <summary> Gets the height of the image if any is set. </summary> | |||||
public int? Height { get; } | public int? Height { get; } | ||||
/// <summary> Gets the width of the image if any is set. </summary> | |||||
public int? Width { get; } | public int? Width { get; } | ||||
internal EmbedImage(string url, string proxyUrl, int? height, int? width) | internal EmbedImage(string url, string proxyUrl, int? height, int? width) | ||||
@@ -1,12 +1,15 @@ | |||||
using System; | |||||
using System; | |||||
using System.Diagnostics; | using System.Diagnostics; | ||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> A provider field for an <see cref="Embed"/>. </summary> | |||||
[DebuggerDisplay("{DebuggerDisplay,nq}")] | [DebuggerDisplay("{DebuggerDisplay,nq}")] | ||||
public struct EmbedProvider | public struct EmbedProvider | ||||
{ | { | ||||
/// <summary> Gets the name of the provider.</summary> | |||||
public string Name { get; } | public string Name { get; } | ||||
/// <summary> Gets the URL of the provider.</summary> | |||||
public string Url { get; } | public string Url { get; } | ||||
internal EmbedProvider(string name, string url) | internal EmbedProvider(string name, string url) | ||||
@@ -1,14 +1,19 @@ | |||||
using System; | |||||
using System; | |||||
using System.Diagnostics; | using System.Diagnostics; | ||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> A thumbnail featured in an <see cref="Embed"/>. </summary> | |||||
[DebuggerDisplay("{DebuggerDisplay,nq}")] | [DebuggerDisplay("{DebuggerDisplay,nq}")] | ||||
public struct EmbedThumbnail | public struct EmbedThumbnail | ||||
{ | { | ||||
/// <summary> Gets the URL of the thumbnail.</summary> | |||||
public string Url { get; } | public string Url { get; } | ||||
/// <summary> Gets the proxified URL of the thumbnail.</summary> | |||||
public string ProxyUrl { get; } | public string ProxyUrl { get; } | ||||
/// <summary> Gets the height of the thumbnail if any is set. </summary> | |||||
public int? Height { get; } | public int? Height { get; } | ||||
/// <summary> Gets the width of the thumbnail if any is set. </summary> | |||||
public int? Width { get; } | public int? Width { get; } | ||||
internal EmbedThumbnail(string url, string proxyUrl, int? height, int? width) | internal EmbedThumbnail(string url, string proxyUrl, int? height, int? width) | ||||
@@ -1,15 +1,25 @@ | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Specifies the type of embed. </summary> | |||||
public enum EmbedType | public enum EmbedType | ||||
{ | { | ||||
/// <summary> An unknown embed type. </summary> | |||||
Unknown = -1, | Unknown = -1, | ||||
/// <summary> A rich embed type. </summary> | |||||
Rich, | Rich, | ||||
/// <summary> A link embed type. </summary> | |||||
Link, | Link, | ||||
/// <summary> A video embed type. </summary> | |||||
Video, | Video, | ||||
/// <summary> An image embed type. </summary> | |||||
Image, | Image, | ||||
/// <summary> A GIFV embed type. </summary> | |||||
Gifv, | Gifv, | ||||
/// <summary> An article embed type. </summary> | |||||
Article, | Article, | ||||
/// <summary> A tweet embed type. </summary> | |||||
Tweet, | Tweet, | ||||
/// <summary> A HTML embed type. </summary> | |||||
Html, | Html, | ||||
} | } | ||||
} | } |
@@ -1,13 +1,17 @@ | |||||
using System; | |||||
using System; | |||||
using System.Diagnostics; | using System.Diagnostics; | ||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> A video featured in an <see cref="Embed"/>. </summary> | |||||
[DebuggerDisplay("{DebuggerDisplay,nq}")] | [DebuggerDisplay("{DebuggerDisplay,nq}")] | ||||
public struct EmbedVideo | public struct EmbedVideo | ||||
{ | { | ||||
/// <summary> Gets the URL of the video. </summary> | |||||
public string Url { get; } | public string Url { get; } | ||||
/// <summary> Gets the height of the video if there is any. </summary> | |||||
public int? Height { get; } | public int? Height { get; } | ||||
/// <summary> Gets the weight of the video if there is any. </summary> | |||||
public int? Width { get; } | public int? Width { get; } | ||||
internal EmbedVideo(string url, int? height, int? width) | internal EmbedVideo(string url, int? height, int? width) | ||||
@@ -1,22 +1,22 @@ | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> The interface that defines an attachment object. </summary> | |||||
/// <summary> Represents a Discord attachment object. </summary> | |||||
public interface IAttachment | public interface IAttachment | ||||
{ | { | ||||
/// <summary> The snowflake ID of the attachment. </summary> | |||||
/// <summary> Gets the snowflake ID of the attachment. </summary> | |||||
ulong Id { get; } | ulong Id { get; } | ||||
/// <summary> The filename of the attachment. </summary> | |||||
/// <summary> Gets the filename of the attachment. </summary> | |||||
string Filename { get; } | string Filename { get; } | ||||
/// <summary> The URL of the attachment. </summary> | |||||
/// <summary> Gets the URL of the attachment. </summary> | |||||
string Url { get; } | string Url { get; } | ||||
/// <summary> The proxied URL of the attachment. </summary> | |||||
/// <summary> Gets the proxied URL of the attachment. </summary> | |||||
string ProxyUrl { get; } | string ProxyUrl { get; } | ||||
/// <summary> The file size of the attachment. </summary> | |||||
/// <summary> Gets the file size of the attachment. </summary> | |||||
int Size { get; } | int Size { get; } | ||||
/// <summary> The height of the attachment if it is an image, or return <see langword="null"/> when it is not. </summary> | |||||
/// <summary> Gets the height of the attachment if it is an image, or return <see langword="null"/> when it is not. </summary> | |||||
int? Height { get; } | int? Height { get; } | ||||
/// <summary> The width of the attachment if it is an image, or return <see langword="null"/> when it is not. </summary> | |||||
/// <summary> Gets the width of the attachment if it is an image, or return <see langword="null"/> when it is not. </summary> | |||||
int? Width { get; } | int? Width { get; } | ||||
} | } | ||||
} | } |
@@ -1,22 +1,36 @@ | |||||
using System; | |||||
using System; | |||||
using System.Collections.Immutable; | using System.Collections.Immutable; | ||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Represents a Discord embed object. </summary> | |||||
public interface IEmbed | public interface IEmbed | ||||
{ | { | ||||
/// <summary> Gets the title URL of the embed. </summary> | |||||
string Url { get; } | string Url { get; } | ||||
/// <summary> Gets the title of the embed. </summary> | |||||
string Title { get; } | string Title { get; } | ||||
/// <summary> Gets the description of the embed. </summary> | |||||
string Description { get; } | string Description { get; } | ||||
/// <summary> Gets the type of the embed. </summary> | |||||
EmbedType Type { get; } | EmbedType Type { get; } | ||||
/// <summary> Gets the timestamp of the embed. </summary> | |||||
DateTimeOffset? Timestamp { get; } | DateTimeOffset? Timestamp { get; } | ||||
/// <summary> Gets the sidebar color of the embed. </summary> | |||||
Color? Color { get; } | Color? Color { get; } | ||||
/// <summary> Gets the image of the embed. </summary> | |||||
EmbedImage? Image { get; } | EmbedImage? Image { get; } | ||||
/// <summary> Gets the video of the embed. </summary> | |||||
EmbedVideo? Video { get; } | EmbedVideo? Video { get; } | ||||
/// <summary> Gets the author field of the embed. </summary> | |||||
EmbedAuthor? Author { get; } | EmbedAuthor? Author { get; } | ||||
/// <summary> Gets the footer field of the embed. </summary> | |||||
EmbedFooter? Footer { get; } | EmbedFooter? Footer { get; } | ||||
/// <summary> Gets the provider of the embed. </summary> | |||||
EmbedProvider? Provider { get; } | EmbedProvider? Provider { get; } | ||||
/// <summary> Gets the thumbnail featured in the embed. </summary> | |||||
EmbedThumbnail? Thumbnail { get; } | EmbedThumbnail? Thumbnail { get; } | ||||
/// <summary> Gets the fields of the embed. </summary> | |||||
ImmutableArray<EmbedField> Fields { get; } | ImmutableArray<EmbedField> Fields { get; } | ||||
} | } | ||||
} | } |
@@ -1,8 +1,9 @@ | |||||
using System; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Represents a Discord message object. </summary> | |||||
public interface IMessage : ISnowflakeEntity, IDeletable | public interface IMessage : ISnowflakeEntity, IDeletable | ||||
{ | { | ||||
/// <summary> Gets the type of this system message. </summary> | /// <summary> Gets the type of this system message. </summary> | ||||
@@ -1,7 +1,9 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Represents a Discord reaction object. </summary> | |||||
public interface IReaction | public interface IReaction | ||||
{ | { | ||||
/// <summary> The <see cref="IEmote"/> used in the reaction. </summary> | |||||
IEmote Emote { get; } | IEmote Emote { get; } | ||||
} | } | ||||
} | } |
@@ -1,9 +1,10 @@ | |||||
using System; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> A Discord message object. </summary> | |||||
public interface IUserMessage : IMessage | public interface IUserMessage : IMessage | ||||
{ | { | ||||
/// <summary> Modifies this message. </summary> | /// <summary> Modifies this message. </summary> | ||||
@@ -1,7 +1,7 @@ | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Properties that are used to modify a message with the specified parameters. | |||||
/// Properties that are used to modify an <see cref="IUserMessage"/> with the specified changes. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
/// The content of a message can be cleared with String.Empty; if and only if an Embed is present. | /// The content of a message can be cleared with String.Empty; if and only if an Embed is present. | ||||
@@ -1,10 +1,15 @@ | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Specifies the source of the Discord message. </summary> | |||||
public enum MessageSource | public enum MessageSource | ||||
{ | { | ||||
/// <summary> The message is sent by the system. </summary> | |||||
System, | System, | ||||
/// <summary> The message is sent by a user. </summary> | |||||
User, | User, | ||||
/// <summary> The message is sent by a bot. </summary> | |||||
Bot, | Bot, | ||||
/// <summary> The message is sent by a webhook. </summary> | |||||
Webhook | Webhook | ||||
} | } | ||||
} | } |
@@ -1,13 +1,21 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Specifies the type of message. </summary> | |||||
public enum MessageType | public enum MessageType | ||||
{ | { | ||||
/// <summary> The default message type. </summary> | |||||
Default = 0, | Default = 0, | ||||
/// <summary> The message when a recipient is added. </summary> | |||||
RecipientAdd = 1, | RecipientAdd = 1, | ||||
/// <summary> The message when a recipient is removed. </summary> | |||||
RecipientRemove = 2, | RecipientRemove = 2, | ||||
/// <summary> The message when a user is called. </summary> | |||||
Call = 3, | Call = 3, | ||||
/// <summary> The message when a channel name is changed. </summary> | |||||
ChannelNameChange = 4, | ChannelNameChange = 4, | ||||
/// <summary> The message when a channel icon is changed. </summary> | |||||
ChannelIconChange = 5, | ChannelIconChange = 5, | ||||
/// <summary> The message when another message is pinned. </summary> | |||||
ChannelPinnedMessage = 6 | ChannelPinnedMessage = 6 | ||||
} | } | ||||
} | } |
@@ -1,11 +1,12 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> A metadata containing reaction information. </summary> | |||||
public struct ReactionMetadata | public struct ReactionMetadata | ||||
{ | { | ||||
/// <summary> Gets the number of reactions </summary> | |||||
/// <summary> Gets the number of reactions. </summary> | |||||
public int ReactionCount { get; internal set; } | public int ReactionCount { get; internal set; } | ||||
/// <summary> Returns true if the current user has used this reaction </summary> | |||||
/// <summary> Returns true if the current user has used this reaction. </summary> | |||||
public bool IsMe { get; internal set; } | public bool IsMe { get; internal set; } | ||||
} | } | ||||
} | } |
@@ -1,13 +1,21 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Specifies the handling type the tag should use. </summary> | |||||
public enum TagHandling | public enum TagHandling | ||||
{ | { | ||||
/// <summary> Tag handling is ignored. </summary> | |||||
Ignore = 0, //<@53905483156684800> -> <@53905483156684800> | Ignore = 0, //<@53905483156684800> -> <@53905483156684800> | ||||
Remove, //<@53905483156684800> -> | |||||
/// <summary> Removes the tag entirely. </summary> | |||||
Remove, //<@53905483156684800> -> | |||||
/// <summary> Resolves to username (e.g. @User). </summary> | |||||
Name, //<@53905483156684800> -> @Voltana | Name, //<@53905483156684800> -> @Voltana | ||||
/// <summary> Resolves to username without mention prefix (e.g. User). </summary> | |||||
NameNoPrefix, //<@53905483156684800> -> Voltana | NameNoPrefix, //<@53905483156684800> -> Voltana | ||||
/// <summary> Resolves to username with discriminator value. (e.g. @User#0001). </summary> | |||||
FullName, //<@53905483156684800> -> @Voltana#8252 | FullName, //<@53905483156684800> -> @Voltana#8252 | ||||
/// <summary> Resolves to username with discriminator value without mention prefix. (e.g. User#0001). </summary> | |||||
FullNameNoPrefix, //<@53905483156684800> -> Voltana#8252 | FullNameNoPrefix, //<@53905483156684800> -> Voltana#8252 | ||||
/// <summary> Sanitizes the tag. </summary> | |||||
Sanitize //<@53905483156684800> -> <@53905483156684800> (w/ nbsp) | Sanitize //<@53905483156684800> -> <@53905483156684800> (w/ nbsp) | ||||
} | } | ||||
} | } |
@@ -1,12 +1,19 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Specifies the type of Discord tag. </summary> | |||||
public enum TagType | public enum TagType | ||||
{ | { | ||||
/// <summary> The object is an user mention. </summary> | |||||
UserMention, | UserMention, | ||||
/// <summary> The object is a channel mention. </summary> | |||||
ChannelMention, | ChannelMention, | ||||
/// <summary> The object is a role mention. </summary> | |||||
RoleMention, | RoleMention, | ||||
/// <summary> The object is an everyone mention. </summary> | |||||
EveryoneMention, | EveryoneMention, | ||||
/// <summary> The object is a here mention. </summary> | |||||
HereMention, | HereMention, | ||||
/// <summary> The object is an emoji. </summary> | |||||
Emoji | Emoji | ||||
} | } | ||||
} | } |
@@ -2,6 +2,7 @@ using System; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Defines the available permissions for a channel. </summary> | |||||
[FlagsAttribute] | [FlagsAttribute] | ||||
public enum ChannelPermission : ulong | public enum ChannelPermission : ulong | ||||
{ | { | ||||
@@ -1,7 +1,8 @@ | |||||
using System; | |||||
using System; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Defines the available permissions for a channel. </summary> | |||||
[FlagsAttribute] | [FlagsAttribute] | ||||
public enum GuildPermission : ulong | public enum GuildPermission : ulong | ||||
{ | { | ||||
@@ -1,9 +1,13 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Specifies the permission value. </summary> | |||||
public enum PermValue | public enum PermValue | ||||
{ | { | ||||
/// <summary> Allows this permission. </summary> | |||||
Allow, | Allow, | ||||
/// <summary> Denies this permission. </summary> | |||||
Deny, | Deny, | ||||
/// <summary> Inherits the permission settings. </summary> | |||||
Inherit | Inherit | ||||
} | } | ||||
} | } |
@@ -3,6 +3,7 @@ using System.Diagnostics; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> A color object that Discord uses. </summary> | |||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
public struct Color | public struct Color | ||||
{ | { | ||||
@@ -1,10 +1,11 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Properties that are used to reorder an <see cref="IRole"/>. </summary> | |||||
public class ReorderRoleProperties | public class ReorderRoleProperties | ||||
{ | { | ||||
/// <summary>The id of the role to be edited</summary> | |||||
/// <summary> Gets the ID of the role to be edited. </summary> | |||||
public ulong Id { get; } | public ulong Id { get; } | ||||
/// <summary>The new zero-based position of the role.</summary> | |||||
/// <summary> Gets the new zero-based position of the role. </summary> | |||||
public int Position { get; } | public int Position { get; } | ||||
public ReorderRoleProperties(ulong id, int pos) | public ReorderRoleProperties(ulong id, int pos) | ||||
@@ -1,7 +1,7 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Modify an IRole with the specified parameters | |||||
/// Properties that are used to modify an <see cref="IRole"/> with the specified changes. | |||||
/// </summary> | /// </summary> | ||||
/// <example> | /// <example> | ||||
/// <code language="c#"> | /// <code language="c#"> | ||||
@@ -16,39 +16,39 @@ | |||||
public class RoleProperties | public class RoleProperties | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// The name of the role | |||||
/// Gets or sets the name of the role. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
/// If this role is the EveryoneRole, this value may not be set. | /// If this role is the EveryoneRole, this value may not be set. | ||||
/// </remarks> | /// </remarks> | ||||
public Optional<string> Name { get; set; } | public Optional<string> Name { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// The role's GuildPermissions | |||||
/// Gets or sets the role's <see cref="GuildPermission"/>. | |||||
/// </summary> | /// </summary> | ||||
public Optional<GuildPermissions> Permissions { get; set; } | public Optional<GuildPermissions> Permissions { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// The position of the role. This is 0-based! | |||||
/// Gets or sets the position of the role. This is 0-based! | |||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
/// If this role is the EveryoneRole, this value may not be set. | /// If this role is the EveryoneRole, this value may not be set. | ||||
/// </remarks> | /// </remarks> | ||||
public Optional<int> Position { get; set; } | public Optional<int> Position { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// The color of the Role. | |||||
/// Gets or sets the color of the Role. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
/// If this role is the EveryoneRole, this value may not be set. | /// If this role is the EveryoneRole, this value may not be set. | ||||
/// </remarks> | /// </remarks> | ||||
public Optional<Color> Color { get; set; } | public Optional<Color> Color { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// Whether or not this role should be displayed independently in the userlist. | |||||
/// Gets or sets whether or not this role should be displayed independently in the userlist. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
/// If this role is the EveryoneRole, this value may not be set. | /// If this role is the EveryoneRole, this value may not be set. | ||||
/// </remarks> | /// </remarks> | ||||
public Optional<bool> Hoist { get; set; } | public Optional<bool> Hoist { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// Whether or not this role can be mentioned. | |||||
/// Gets or sets whether or not this role can be mentioned. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
/// If this role is the EveryoneRole, this value may not be set. | /// If this role is the EveryoneRole, this value may not be set. | ||||
@@ -1,5 +1,6 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Represents a Discord user that is in a group. </summary> | |||||
public interface IGroupUser : IUser, IVoiceState | public interface IGroupUser : IUser, IVoiceState | ||||
{ | { | ||||
///// <summary> Kicks this user from this group. </summary> | ///// <summary> Kicks this user from this group. </summary> | ||||
@@ -1,10 +1,10 @@ | |||||
using System; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> A Guild-User pairing. </summary> | |||||
/// <summary> Represents a Discord user that is in a guild. </summary> | |||||
public interface IGuildUser : IUser, IVoiceState | public interface IGuildUser : IUser, IVoiceState | ||||
{ | { | ||||
/// <summary> Gets when this user joined this guild. </summary> | /// <summary> Gets when this user joined this guild. </summary> | ||||
@@ -1,5 +1,6 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Represents a Discord user's presence status. </summary> | |||||
public interface IPresence | public interface IPresence | ||||
{ | { | ||||
/// <summary> Gets the activity this user is currently doing. </summary> | /// <summary> Gets the activity this user is currently doing. </summary> | ||||
@@ -7,4 +8,4 @@ | |||||
/// <summary> Gets the current status of this user. </summary> | /// <summary> Gets the current status of this user. </summary> | ||||
UserStatus Status { get; } | UserStatus Status { get; } | ||||
} | } | ||||
} | |||||
} |
@@ -3,6 +3,7 @@ using System.Threading.Tasks; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Represents a logged-in Discord user. </summary> | |||||
public interface ISelfUser : IUser | public interface ISelfUser : IUser | ||||
{ | { | ||||
/// <summary> Gets the email associated with this user. </summary> | /// <summary> Gets the email associated with this user. </summary> | ||||
@@ -14,4 +15,4 @@ namespace Discord | |||||
Task ModifyAsync(Action<SelfUserProperties> func, RequestOptions options = null); | Task ModifyAsync(Action<SelfUserProperties> func, RequestOptions options = null); | ||||
} | } | ||||
} | |||||
} |
@@ -2,6 +2,7 @@ using System.Threading.Tasks; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Represents a Discord user. </summary> | |||||
public interface IUser : ISnowflakeEntity, IMentionable, IPresence | public interface IUser : ISnowflakeEntity, IMentionable, IPresence | ||||
{ | { | ||||
/// <summary> Gets the id of this user's avatar. </summary> | /// <summary> Gets the id of this user's avatar. </summary> | ||||
@@ -1,5 +1,6 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Represents a Webhook Discord user. </summary> | |||||
public interface IWebhookUser : IGuildUser | public interface IWebhookUser : IGuildUser | ||||
{ | { | ||||
ulong WebhookId { get; } | ulong WebhookId { get; } | ||||
@@ -1,7 +1,7 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Modify the current user with the specified arguments | |||||
/// Properties that are used to modify the <see cref="ISelfUser"/> with the specified changes. | |||||
/// </summary> | /// </summary> | ||||
/// <example> | /// <example> | ||||
/// <code language="c#"> | /// <code language="c#"> | ||||
@@ -1,12 +1,19 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Defines the available Discord user status. </summary> | |||||
public enum UserStatus | public enum UserStatus | ||||
{ | { | ||||
/// <summary> The user is offline. </summary> | |||||
Offline, | Offline, | ||||
/// <summary> The user is online. </summary> | |||||
Online, | Online, | ||||
/// <summary> The user is idle. </summary> | |||||
Idle, | Idle, | ||||
/// <summary> The user is AFK. </summary> | |||||
AFK, | AFK, | ||||
/// <summary> The user is busy. </summary> | |||||
DoNotDisturb, | DoNotDisturb, | ||||
/// <summary> The user is invisible. </summary> | |||||
Invisible, | Invisible, | ||||
} | } | ||||
} | } |
@@ -1,7 +1,7 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Modify an <see cref="IWebhook"/> with the specified parameters. | |||||
/// Properties used to modify an <see cref="IWebhook"/> with the specified changes. | |||||
/// </summary> | /// </summary> | ||||
/// <example> | /// <example> | ||||
/// <code language="c#"> | /// <code language="c#"> | ||||
@@ -16,22 +16,22 @@ | |||||
public class WebhookProperties | public class WebhookProperties | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// The default name of the webhook. | |||||
/// Gets or sets the default name of the webhook. | |||||
/// </summary> | /// </summary> | ||||
public Optional<string> Name { get; set; } | public Optional<string> Name { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// The default avatar of the webhook. | |||||
/// Gets or sets the default avatar of the webhook. | |||||
/// </summary> | /// </summary> | ||||
public Optional<Image?> Image { get; set; } | public Optional<Image?> Image { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// The channel for this webhook. | |||||
/// Gets or sets the channel for this webhook. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
/// This field is not used when authenticated with <see cref="TokenType.Webhook"/>. | /// This field is not used when authenticated with <see cref="TokenType.Webhook"/>. | ||||
/// </remarks> | /// </remarks> | ||||
public Optional<ITextChannel> Channel { get; set; } | public Optional<ITextChannel> Channel { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// The channel id for this webhook. | |||||
/// Gets or sets the channel ID for this webhook. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
/// This field is not used when authenticated with <see cref="TokenType.Webhook"/>. | /// This field is not used when authenticated with <see cref="TokenType.Webhook"/>. | ||||
@@ -1,24 +1,31 @@ | |||||
using System.Collections.Generic; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | using System.Linq; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Extensions for <see cref="IDiscordClient"/>. </summary> | |||||
public static class DiscordClientExtensions | public static class DiscordClientExtensions | ||||
{ | { | ||||
/// <summary> Gets the private channel with the provided ID. </summary> | |||||
public static async Task<IPrivateChannel> GetPrivateChannelAsync(this IDiscordClient client, ulong id) | public static async Task<IPrivateChannel> GetPrivateChannelAsync(this IDiscordClient client, ulong id) | ||||
=> await client.GetChannelAsync(id).ConfigureAwait(false) as IPrivateChannel; | => await client.GetChannelAsync(id).ConfigureAwait(false) as IPrivateChannel; | ||||
/// <summary> Gets the DM channel with the provided ID. </summary> | |||||
public static async Task<IDMChannel> GetDMChannelAsync(this IDiscordClient client, ulong id) | public static async Task<IDMChannel> GetDMChannelAsync(this IDiscordClient client, ulong id) | ||||
=> await client.GetPrivateChannelAsync(id).ConfigureAwait(false) as IDMChannel; | => await client.GetPrivateChannelAsync(id).ConfigureAwait(false) as IDMChannel; | ||||
/// <summary> Gets all available DM channels for the client. </summary> | |||||
public static async Task<IEnumerable<IDMChannel>> GetDMChannelsAsync(this IDiscordClient client) | public static async Task<IEnumerable<IDMChannel>> GetDMChannelsAsync(this IDiscordClient client) | ||||
=> (await client.GetPrivateChannelsAsync().ConfigureAwait(false)).Select(x => x as IDMChannel).Where(x => x != null); | => (await client.GetPrivateChannelsAsync().ConfigureAwait(false)).Select(x => x as IDMChannel).Where(x => x != null); | ||||
/// <summary> Gets the group channel with the provided ID. </summary> | |||||
public static async Task<IGroupChannel> GetGroupChannelAsync(this IDiscordClient client, ulong id) | public static async Task<IGroupChannel> GetGroupChannelAsync(this IDiscordClient client, ulong id) | ||||
=> await client.GetPrivateChannelAsync(id).ConfigureAwait(false) as IGroupChannel; | => await client.GetPrivateChannelAsync(id).ConfigureAwait(false) as IGroupChannel; | ||||
/// <summary> Gets all available group channels for the client. </summary> | |||||
public static async Task<IEnumerable<IGroupChannel>> GetGroupChannelsAsync(this IDiscordClient client) | public static async Task<IEnumerable<IGroupChannel>> GetGroupChannelsAsync(this IDiscordClient client) | ||||
=> (await client.GetPrivateChannelsAsync().ConfigureAwait(false)).Select(x => x as IGroupChannel).Where(x => x != null); | => (await client.GetPrivateChannelsAsync().ConfigureAwait(false)).Select(x => x as IGroupChannel).Where(x => x != null); | ||||
/// <summary> Gets the most optimal voice region for the client. </summary> | |||||
public static async Task<IVoiceRegion> GetOptimalVoiceRegionAsync(this IDiscordClient discord) | public static async Task<IVoiceRegion> GetOptimalVoiceRegionAsync(this IDiscordClient discord) | ||||
{ | { | ||||
var regions = await discord.GetVoiceRegionsAsync().ConfigureAwait(false); | var regions = await discord.GetVoiceRegionsAsync().ConfigureAwait(false); | ||||
@@ -2,6 +2,7 @@ using System; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Extensions for building an embed. </summary> | |||||
public static class EmbedBuilderExtensions | public static class EmbedBuilderExtensions | ||||
{ | { | ||||
/// <summary> Adds embed color based on the provided raw value. </summary> | /// <summary> Adds embed color based on the provided raw value. </summary> | ||||
@@ -1,5 +1,6 @@ | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Specifies the severity of the log message. </summary> | |||||
public enum LogSeverity | public enum LogSeverity | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
@@ -1,10 +1,15 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> Specifies the state of the client's login status. </summary> | |||||
public enum LoginState : byte | public enum LoginState : byte | ||||
{ | { | ||||
/// <summary> The client is currently logged out. </summary> | |||||
LoggedOut, | LoggedOut, | ||||
/// <summary> The client is currently logging in. </summary> | |||||
LoggingIn, | LoggingIn, | ||||
/// <summary> The client is currently logged in. </summary> | |||||
LoggedIn, | LoggedIn, | ||||
/// <summary> The client is currently logging out. </summary> | |||||
LoggingOut | LoggingOut | ||||
} | } | ||||
} | } |
@@ -2,6 +2,7 @@ using System; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Specifies the type of token to use with the client. </summary> | |||||
public enum TokenType | public enum TokenType | ||||
{ | { | ||||
[Obsolete("User logins are deprecated and may result in a ToS strike against your account - please see https://github.com/RogueException/Discord.Net/issues/827", error: true)] | [Obsolete("User logins are deprecated and may result in a ToS strike against your account - please see https://github.com/RogueException/Discord.Net/issues/827", error: true)] | ||||