diff --git a/src/Discord.Net.Commands/Attributes/PriorityAttribute.cs b/src/Discord.Net.Commands/Attributes/PriorityAttribute.cs
new file mode 100644
index 000000000..5120bb7d1
--- /dev/null
+++ b/src/Discord.Net.Commands/Attributes/PriorityAttribute.cs
@@ -0,0 +1,18 @@
+using System;
+
+namespace Discord.Commands
+{
+ /// Sets priority of commands
+ [AttributeUsage(AttributeTargets.Method)]
+ public class PriorityAttribute : Attribute
+ {
+ /// The priority which has been set for the command
+ public int Priority { get; }
+
+ /// Creates a new with the given priority.
+ public PriorityAttribute(int priority)
+ {
+ Priority = priority;
+ }
+ }
+}
diff --git a/src/Discord.Net.Commands/Command.cs b/src/Discord.Net.Commands/Command.cs
index b191b5786..b7b7da401 100644
--- a/src/Discord.Net.Commands/Command.cs
+++ b/src/Discord.Net.Commands/Command.cs
@@ -24,6 +24,7 @@ namespace Discord.Commands
public string Summary { get; }
public string Remarks { get; }
public string Text { get; }
+ public int Priority { get; }
public bool HasVarArgs { get; }
public IReadOnlyList Aliases { get; }
public IReadOnlyList Parameters { get; }
@@ -70,6 +71,9 @@ namespace Discord.Commands
if (remarksAttr != null)
Remarks = remarksAttr.Text;
+ var priorityAttr = source.GetCustomAttribute();
+ Priority = priorityAttr?.Priority ?? 0;
+
Parameters = BuildParameters(source);
HasVarArgs = Parameters.Count > 0 ? Parameters[Parameters.Count - 1].IsMultiple : false;
Preconditions = BuildPreconditions(source);
diff --git a/src/Discord.Net.Commands/CommandService.cs b/src/Discord.Net.Commands/CommandService.cs
index 814277b04..344950e68 100644
--- a/src/Discord.Net.Commands/CommandService.cs
+++ b/src/Discord.Net.Commands/CommandService.cs
@@ -180,7 +180,7 @@ namespace Discord.Commands
public SearchResult Search(IUserMessage message, string input)
{
string lowerInput = input.ToLowerInvariant();
- var matches = _map.GetCommands(input).ToImmutableArray();
+ var matches = _map.GetCommands(input).OrderByDescending(x => x.Priority).ToImmutableArray();
if (matches.Length > 0)
return SearchResult.FromSuccess(input, matches);