You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

CommandServiceConfig.cs 1.5 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. namespace Discord.Commands
  3. {
  4. public enum HelpMode
  5. {
  6. /// <summary> Disable the automatic help command. </summary>
  7. Disable,
  8. /// <summary> Use the automatic help command and respond in the channel the command is used. </summary>
  9. Public,
  10. /// <summary> Use the automatic help command and respond in a private message. </summary>
  11. Private
  12. }
  13. public class CommandServiceConfig
  14. {
  15. public Func<User, int> PermissionResolver { get { return _permissionsResolver; } set { SetValue(ref _permissionsResolver, value); } }
  16. private Func<User, int> _permissionsResolver;
  17. public char? CommandChar
  18. {
  19. get
  20. {
  21. return _commandChars.Length > 0 ? _commandChars[0] : (char?)null;
  22. }
  23. set
  24. {
  25. if (value != null)
  26. CommandChars = new char[] { value.Value };
  27. else
  28. CommandChars = new char[0];
  29. }
  30. }
  31. public char[] CommandChars { get { return _commandChars; } set { SetValue(ref _commandChars, value); } }
  32. private char[] _commandChars = new char[] { '!' };
  33. public HelpMode HelpMode { get { return _helpMode; } set { SetValue(ref _helpMode, value); } }
  34. private HelpMode _helpMode = HelpMode.Disable;
  35. //Lock
  36. protected bool _isLocked;
  37. internal void Lock() { _isLocked = true; }
  38. protected void SetValue<T>(ref T storage, T value)
  39. {
  40. if (_isLocked)
  41. throw new InvalidOperationException("Unable to modify a discord client's configuration after it has been created.");
  42. storage = value;
  43. }
  44. }
  45. }