Browse Source

Revert back to auto property, fire method at end of SetContext().

pull/499/head
Joe4evr 8 years ago
parent
commit
ba8fbdb916
1 changed files with 3 additions and 11 deletions
  1. +3
    -11
      src/Discord.Net.Commands/ModuleBase.cs

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

@@ -8,23 +8,14 @@ namespace Discord.Commands
public abstract class ModuleBase<T> : IModuleBase public abstract class ModuleBase<T> : IModuleBase
where T : class, ICommandContext where T : class, ICommandContext
{ {
public T Context
{
get { return _context; }
private set
{
_context = value;
ContextSet();
}
}
private T _context;
public T Context { get; private set; }


protected virtual async Task<IUserMessage> ReplyAsync(string message, bool isTTS = false, Embed embed = null, RequestOptions options = null) protected virtual async Task<IUserMessage> ReplyAsync(string message, bool isTTS = false, Embed embed = null, RequestOptions options = null)
{ {
return await Context.Channel.SendMessageAsync(message, isTTS, embed, options).ConfigureAwait(false); return await Context.Channel.SendMessageAsync(message, isTTS, embed, options).ConfigureAwait(false);
} }
protected virtual void ContextSet()
protected virtual void OnContextSet()
{ {
} }


@@ -35,6 +26,7 @@ namespace Discord.Commands
if (newValue == null) if (newValue == null)
throw new InvalidOperationException($"Invalid context type. Expected {typeof(T).Name}, got {context.GetType().Name}"); throw new InvalidOperationException($"Invalid context type. Expected {typeof(T).Name}, got {context.GetType().Name}");
Context = newValue; Context = newValue;
OnContextSet();
} }
} }
} }

Loading…
Cancel
Save