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.3 kB

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