Browse Source

Merge 57e0f78803 into 431b7fbd9f

pull/535/merge
Finite Reality GitHub 8 years ago
parent
commit
aad67e70a9
3 changed files with 10 additions and 5 deletions
  1. +3
    -3
      src/Discord.Net.Commands/CommandService.cs
  2. +6
    -1
      src/Discord.Net.Commands/IModuleBase.cs
  3. +1
    -1
      src/Discord.Net.Commands/ModuleBase.cs

+ 3
- 3
src/Discord.Net.Commands/CommandService.cs View File

@@ -83,7 +83,7 @@ namespace Discord.Commands
_moduleLock.Release();
}
}
public async Task<ModuleInfo> AddModuleAsync<T>()
public async Task<ModuleInfo> AddModuleAsync<T>() where T : IModuleBase<ICommandContext>
{
await _moduleLock.WaitAsync().ConfigureAwait(false);
try
@@ -96,7 +96,7 @@ namespace Discord.Commands
var module = ModuleClassBuilder.Build(this, typeInfo).FirstOrDefault();

if (module.Value == default(ModuleInfo))
throw new InvalidOperationException($"Could not build the module {typeof(T).FullName}, did you pass an invalid type?");
throw new InvalidOperationException($"Could not build the module {typeof(T).FullName}");

_typedModuleDefs[module.Key] = module.Value;

@@ -153,7 +153,7 @@ namespace Discord.Commands
_moduleLock.Release();
}
}
public async Task<bool> RemoveModuleAsync<T>()
public async Task<bool> RemoveModuleAsync<T>() where T : IModuleBase<ICommandContext>
{
await _moduleLock.WaitAsync().ConfigureAwait(false);
try


+ 6
- 1
src/Discord.Net.Commands/IModuleBase.cs View File

@@ -1,5 +1,10 @@
namespace Discord.Commands
namespace Discord.Commands
{
public interface IModuleBase<out T>
where T : ICommandContext
{
}

internal interface IModuleBase
{
void SetContext(ICommandContext context);


+ 1
- 1
src/Discord.Net.Commands/ModuleBase.cs View File

@@ -5,7 +5,7 @@ namespace Discord.Commands
{
public abstract class ModuleBase : ModuleBase<ICommandContext> { }

public abstract class ModuleBase<T> : IModuleBase
public abstract class ModuleBase<T> : IModuleBase, IModuleBase<T>
where T : class, ICommandContext
{
public T Context { get; private set; }


Loading…
Cancel
Save