/// <summary> /// Initializes a new <see cref="SocketSubmissionAdapter"/>. /// </summary> /// <param name="apiClient">The <see cref="DblClient"/> for this <see cref="SocketSubmissionAdapter"/> to use.</param> /// <param name="client">The <see cref="BaseDiscordClient"/> for this <see cref="SocketSubmissionAdapter"/> to use.</param> /// <param name="properties">The properties of this <see cref="SocketSubmissionAdapter"/>.</param> public SocketSubmissionAdapter(DblClient apiClient, BaseSocketClient client, AdapterProperties properties = null) { if (apiClient.CurrentUserId != client.CurrentUser.Id) { throw new ArgumentException("The DblClient must reference the specified current user in the IDiscordClient"); } ApiClient = apiClient; Client = client; properties = properties ?? AdapterProperties.Default; Interval = properties.Interval; RunMode = properties.RunMode; Message = properties.Message; if (RunMode == AdapterRunMode.Async) { Timer = new Timer(UpdateInternal, this, Interval, Interval); } else { Client.JoinedGuild += UpdateAsync; Client.LeftGuild += UpdateAsync; } }
/// <summary> /// Initializes a new <see cref="SubmissionAdapter"/>. /// </summary> /// <param name="apiClient">The <see cref="DblClient"/> for this <see cref="SubmissionAdapter"/> to use.</param> /// <param name="client">The <see cref="BaseDiscordClient"/> for this <see cref="SubmissionAdapter"/> to use.</param> /// <param name="properties">The properties of this <see cref="SubmissionAdapter"/> (<see cref="AdapterProperties.RunMode"/> is omitted).</param> public SubmissionAdapter(DblClient apiClient, IDiscordClient client, AdapterProperties properties = null) { if (apiClient.CurrentUserId != client.CurrentUser.Id) { throw new ArgumentException("The DblClient must reference the specified current user in the IDiscordClient"); } ApiClient = apiClient; Client = client; properties = properties ?? AdapterProperties.Default; Interval = properties.Interval; Message = properties.Message; Timer = new Timer(UpdateInternal, this, Interval, Interval); }