Browse Source

init

pull/2025/head
Cenk Ergen 3 years ago
parent
commit
d6d7a61d71
2 changed files with 17 additions and 2 deletions
  1. +16
    -1
      src/Discord.Net.Interactions/Info/Commands/CommandInfo.cs
  2. +1
    -1
      src/Discord.Net.Interactions/Info/ModuleInfo.cs

+ 16
- 1
src/Discord.Net.Interactions/Info/Commands/CommandInfo.cs View File

@@ -50,7 +50,7 @@ namespace Discord.Interactions
public abstract bool SupportsWildCards { get; }

/// <inheritdoc/>
public bool IsTopLevelCommand => IgnoreGroupNames || !Module.IsTopLevelGroup;
public bool IsTopLevelCommand { get; }

/// <inheritdoc/>
public RunMode RunMode { get; }
@@ -72,6 +72,7 @@ namespace Discord.Interactions
Name = builder.Name;
MethodName = builder.MethodName;
IgnoreGroupNames = builder.IgnoreGroupNames;
IsTopLevelCommand = IgnoreGroupNames || CheckTopLevel(Module);
RunMode = builder.RunMode != RunMode.Default ? builder.RunMode : commandService._runMode;
Attributes = builder.Attributes.ToImmutableArray();
Preconditions = builder.Preconditions.ToImmutableArray();
@@ -230,6 +231,20 @@ namespace Discord.Interactions
}
}

private static bool CheckTopLevel(ModuleInfo parent)
{
var currentParent = parent;

while (currentParent != null)
{
if (currentParent.IsTopLevelGroup)
return false;

currentParent = currentParent.Parent;
}
return true;
}

// ICommandInfo

/// <inheritdoc/>


+ 1
- 1
src/Discord.Net.Interactions/Info/ModuleInfo.cs View File

@@ -115,7 +115,7 @@ namespace Discord.Interactions
SubModules = BuildSubModules(builder, commandService, services).ToImmutableArray();
Attributes = BuildAttributes(builder).ToImmutableArray();
Preconditions = BuildPreconditions(builder).ToImmutableArray();
IsTopLevelGroup = CheckTopLevel(parent);
IsTopLevelGroup = IsSlashGroup && CheckTopLevel(parent);
DontAutoRegister = builder.DontAutoRegister;

GroupedPreconditions = Preconditions.ToLookup(x => x.Group, x => x, StringComparer.Ordinal);


Loading…
Cancel
Save