Hide aliases from default help
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Discord.Commands
|
||||
{
|
||||
@@ -11,15 +10,15 @@ namespace Discord.Commands
|
||||
|
||||
private readonly List<Command> _commands;
|
||||
private readonly Dictionary<string, CommandMap> _items;
|
||||
private bool _isHidden;
|
||||
private bool _isVisible, _hasNonAliases, _hasSubGroups;
|
||||
|
||||
public string Name => _name;
|
||||
public string FullName => _fullName;
|
||||
public bool IsHidden => _isHidden;
|
||||
public bool IsVisible => _isVisible;
|
||||
public bool HasNonAliases => _hasNonAliases;
|
||||
public bool HasSubGroups => _hasSubGroups;
|
||||
public IEnumerable<Command> Commands => _commands;
|
||||
public IEnumerable<CommandMap> SubGroups => _items.Values;
|
||||
/*public IEnumerable<Command> SubCommands => _items.Select(x => x.Value._command).Where(x => x != null);
|
||||
public IEnumerable<CommandMap> SubGroups => _items.Select(x => x.Value).Where(x => x._items.Count > 0);*/
|
||||
|
||||
public CommandMap(CommandMap parent, string name, string fullName)
|
||||
{
|
||||
@@ -28,7 +27,9 @@ namespace Discord.Commands
|
||||
_fullName = fullName;
|
||||
_items = new Dictionary<string, CommandMap>();
|
||||
_commands = new List<Command>();
|
||||
_isHidden = true;
|
||||
_isVisible = false;
|
||||
_hasNonAliases = false;
|
||||
_hasSubGroups = false;
|
||||
}
|
||||
|
||||
public CommandMap GetItem(string text)
|
||||
@@ -81,29 +82,34 @@ namespace Discord.Commands
|
||||
return null;
|
||||
}
|
||||
|
||||
public void AddCommand(string text, Command command)
|
||||
public void AddCommand(string text, Command command, bool isAlias)
|
||||
{
|
||||
AddCommand(0, text.Split(' '), command);
|
||||
AddCommand(0, text.Split(' '), command, isAlias);
|
||||
}
|
||||
private void AddCommand(int index, string[] parts, Command command)
|
||||
private void AddCommand(int index, string[] parts, Command command, bool isAlias)
|
||||
{
|
||||
if (!command.IsHidden && _isHidden)
|
||||
_isHidden = false;
|
||||
if (!command.IsHidden)
|
||||
_isVisible = true;
|
||||
|
||||
if (index != parts.Length)
|
||||
{
|
||||
CommandMap nextGroup;
|
||||
string name = parts[index].ToLowerInvariant();
|
||||
string fullName = string.Join(" ", parts, 0, index + 1);
|
||||
if (!_items.TryGetValue(name, out nextGroup))
|
||||
if (!_items.TryGetValue(name, out nextGroup))
|
||||
{
|
||||
nextGroup = new CommandMap(this, name, fullName);
|
||||
_items.Add(name, nextGroup);
|
||||
_hasSubGroups = true;
|
||||
}
|
||||
nextGroup.AddCommand(index + 1, parts, command);
|
||||
}
|
||||
nextGroup.AddCommand(index + 1, parts, command, isAlias);
|
||||
}
|
||||
else
|
||||
{
|
||||
_commands.Add(command);
|
||||
if (!isAlias)
|
||||
_hasNonAliases = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanRun(User user, Channel channel, out string error)
|
||||
|
||||
Reference in New Issue
Block a user