Browse Source

Added DiscordConfig.Mode

tags/docs-0.9
RogueException 9 years ago
parent
commit
11e7c06402
2 changed files with 15 additions and 3 deletions
  1. +12
    -3
      src/Discord.Net/DiscordConfig.cs
  2. +3
    -0
      src/Discord.Net/Models/Message.cs

+ 12
- 3
src/Discord.Net/DiscordConfig.cs View File

@@ -5,6 +5,13 @@ using System.Text;


namespace Discord namespace Discord
{ {
public enum DiscordMode
{
/// <summary> Enable bot-only functions. Use this mode if you are creating a bot, automated application, or interface. </summary>
Bot = 0,
/// <summary> Enables client-only functions. Use this mode if you are creating a custom client. </summary>
Client
}
public enum LogSeverity : byte public enum LogSeverity : byte
{ {
Error = 1, Error = 1,
@@ -45,11 +52,13 @@ namespace Discord
/// <summary> Enables or disables the default event logger. </summary> /// <summary> Enables or disables the default event logger. </summary>
public bool LogEvents { get { return _logEvents; } set { SetValue(ref _logEvents, value); } } public bool LogEvents { get { return _logEvents; } set { SetValue(ref _logEvents, value); } }
private bool _logEvents = true; private bool _logEvents = true;
/// <summary> Specifies the mode that this application should run in. </summary>
public DiscordMode Mode { get { return _mode; } set { SetValue(ref _mode, value); } }
private DiscordMode _mode = DiscordMode.Bot;


/// <summary> User Agent string to use when connecting to Discord. </summary> /// <summary> User Agent string to use when connecting to Discord. </summary>
[JsonIgnore] [JsonIgnore]
public string UserAgent { get { return _userAgent; } }
private string _userAgent;
public string UserAgent { get; private set; }


//Rest //Rest


@@ -120,7 +129,7 @@ namespace Discord
builder.Append(' '); builder.Append(' ');
} }
builder.Append($"DiscordBot ({LibUrl}, v{LibVersion})"); builder.Append($"DiscordBot ({LibUrl}, v{LibVersion})");
_userAgent = builder.ToString();
UserAgent = builder.ToString();
} }
} }
} }

+ 3
- 0
src/Discord.Net/Models/Message.cs View File

@@ -340,6 +340,9 @@ namespace Discord
public Task Acknowledge() public Task Acknowledge()
{ {
if (Client.Config.Mode != DiscordMode.Client)
throw new InvalidOperationException("Message.Acknowledge may only be used in Client mode.");

if (User.Id != Client.CurrentUser.Id) if (User.Id != Client.CurrentUser.Id)
return Client.ClientAPI.Send(new AckMessageRequest(Channel.Id, Id)); return Client.ClientAPI.Send(new AckMessageRequest(Channel.Id, Id));
else else


Loading…
Cancel
Save