/// <summary> Gets the internal WebSocket for the Gateway event stream. </summary>
/// <summary> Gets the internal WebSocket for the Gateway event stream. </summary>
public GatewaySocket GatewaySocket { get; }
public GatewaySocket GatewaySocket { get; }
/// <summary> Gets the service manager used for adding extensions to this client. </summary>
public ServiceManager Services { get; }
/// <summary> Gets the queue used for outgoing messages, if enabled. </summary>
/// <summary> Gets the queue used for outgoing messages, if enabled. </summary>
public MessageQueue MessageQueue { get; }
public MessageQueue MessageQueue { get; }
/// <summary> Gets the JSON serializer used by this client. </summary>
/// <summary> Gets the JSON serializer used by this client. </summary>
@@ -66,6 +65,8 @@ namespace Discord
/// <summary> Gets the game the current user is displayed as playing. </summary>
/// <summary> Gets the game the current user is displayed as playing. </summary>
public string CurrentGame { get; private set; }
public string CurrentGame { get; private set; }
/// <summary> Gets a collection of all extensions added to this DiscordClient. </summary>
public IEnumerable<IService> Services => _services;
/// <summary> Gets a collection of all servers this client is a member of. </summary>
/// <summary> Gets a collection of all servers this client is a member of. </summary>
public IEnumerable<Server> Servers => _servers.Select(x => x.Value);
public IEnumerable<Server> Servers => _servers.Select(x => x.Value);
/// <summary> Gets a collection of all private channels this client is a member of. </summary>
/// <summary> Gets a collection of all private channels this client is a member of. </summary>
@@ -152,7 +153,7 @@ namespace Discord
MessageQueue = new MessageQueue(ClientAPI, Log.CreateLogger("MessageQueue"));
MessageQueue = new MessageQueue(ClientAPI, Log.CreateLogger("MessageQueue"));
//Extensibility
//Extensibility
Services = new ServiceManager(this);
_services = new ServiceCollection(this);
}
}
/// <summary> Connects to the Discord server with the provided email and password. </summary>
/// <summary> Connects to the Discord server with the provided email and password. </summary>
@@ -1010,6 +1011,18 @@ namespace Discord
}
}
#endregion
#endregion
#region Services
public T AddService<T>(T instance)
where T : class, IService
=> _services.Add(instance);
public T AddService<T>()
where T : class, IService, new()
=> _services.Add(new T());
public T GetService<T>(bool isRequired = true)
where T : class, IService
=> _services.Get<T>(isRequired);
#endregion
#region Async Wrapper
#region Async Wrapper
/// <summary> Blocking call that will execute the provided async method and wait until the client has been manually stopped. This is mainly intended for use in console applications. </summary>
/// <summary> Blocking call that will execute the provided async method and wait until the client has been manually stopped. This is mainly intended for use in console applications. </summary>
public void ExecuteAndWait(Func<Task> asyncAction)
public void ExecuteAndWait(Func<Task> asyncAction)
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.