/// <summary> /// Executes this webhook, i.e. sends a message from it. /// </summary> /// <param name="client"> The webhook client. </param> /// <param name="message"> The message to send. </param> /// <param name="threadId"> The ID of the thread (within the webhook's channel) in which this request should be performed. </param> /// <param name="wait"> Whether the API should return the sent message object. </param> /// <param name="options"> The optional request options. </param> /// <param name="cancellationToken"> The cancellation token to observe. </param> /// <returns> /// A <see cref="Task{TResult}"/> representing the asynchronous request /// that wraps the returned <see cref="IUserMessage"/> if <paramref name="wait"/> is <see langword="true"/>. /// </returns> public static Task <IUserMessage> ExecuteAsync(this IWebhookClient client, LocalWebhookMessage message, Snowflake?threadId = null, bool wait = false, IRestRequestOptions options = null, CancellationToken cancellationToken = default) { return(client.RestClient.ExecuteWebhookAsync(client.Id, client.Token, message, threadId, wait, options, cancellationToken)); }
/// <summary> /// Fetch a message sent by this webhook. /// </summary> /// <param name="client"> The webhook client. </param> /// <param name="messageId"> The ID of the message to fetch. </param> /// <param name="threadId"> The ID of the thread (within the webhook's channel) in which this request should be performed. </param> /// <param name="options"> The optional request options. </param> /// <param name="cancellationToken"> The cancellation token to observe. </param> /// <returns> /// A <see cref="Task"/> representing the asynchronous request. /// </returns> public static Task <IUserMessage> FetchMessageAsync(this IWebhookClient client, Snowflake messageId, Snowflake?threadId = null, IRestRequestOptions options = null, CancellationToken cancellationToken = default) { return(client.RestClient.FetchWebhookMessageAsync(client.Id, client.Token, messageId, threadId, options, cancellationToken)); }
/// <summary> /// Modifies a message sent by this webhook. /// </summary> /// <param name="client"> The webhook client. </param> /// <param name="messageId"> The ID of the message to modify. </param> /// <param name="action"> The action specifying what properties to modify. </param> /// <param name="threadId"> The ID of the thread (within the webhook's channel) in which this request should be performed. </param> /// <param name="options"> The optional request options. </param> /// <param name="cancellationToken"> The cancellation token to observe. </param> /// <returns> /// A <see cref="Task{TResult}"/> representing the asynchronous request /// that wraps the updated <see cref="IUserMessage"/>. /// </returns> public static Task <IUserMessage> ModifyMessageAsync(this IWebhookClient client, Snowflake messageId, Action <ModifyWebhookMessageActionProperties> action, Snowflake?threadId = null, IRestRequestOptions options = null, CancellationToken cancellationToken = default) { return(client.RestClient.ModifyWebhookMessageAsync(client.Id, client.Token, messageId, action, threadId, options, cancellationToken)); }
/// <summary> /// Initializes a new instance of the <see cref="WebhookSender"/> class. /// </summary> /// <param name="logger">Instance of the <see cref="ILogger{WebhookSender}"/> interface.</param> /// <param name="discordClient">Instance of <see cref="IWebhookClient{DiscordOption}"/>.</param> /// /// <param name="genericClient">Instance of the <see cref="IWebhookClient{GenericOption}"/>.</param> /// <param name="genericFormClient">Instance of the <see cref="IWebhookClient{GenericFormOption}"/>.</param> /// <param name="gotifyClient">Instance of <see cref="IWebhookClient{GotifyOption}"/>.</param> /// <param name="pushbulletClient">Instance of the <see cref="IWebhookClient{PushbulletOption}"/>.</param> /// <param name="pushoverClient">Instance of the <see cref="IWebhookClient{PushoverOption}"/>.</param> /// <param name="slackClient">Instance of the <see cref="IWebhookClient{SlackOption}"/>.</param> /// <param name="smtpClient">Instance of the <see cref="IWebhookClient{SmtpOption}"/>.</param> public WebhookSender( ILogger <WebhookSender> logger, IWebhookClient <DiscordOption> discordClient, IWebhookClient <GenericOption> genericClient, IWebhookClient <GenericFormOption> genericFormClient, IWebhookClient <GotifyOption> gotifyClient, IWebhookClient <PushbulletOption> pushbulletClient, IWebhookClient <PushoverOption> pushoverClient, IWebhookClient <SlackOption> slackClient, IWebhookClient <SmtpOption> smtpClient) { _logger = logger; _discordClient = discordClient; _genericClient = genericClient; _genericFormClient = genericFormClient; _gotifyClient = gotifyClient; _pushbulletClient = pushbulletClient; _pushoverClient = pushoverClient; _slackClient = slackClient; _smtpClient = smtpClient; }
/// <summary> /// Deletes this webhook. /// </summary> /// <param name="client"> The webhook client. </param> /// <param name="options"> The optional request options. </param> /// <param name="cancellationToken"> The cancellation token to observe. </param> /// <returns> /// A <see cref="Task"/> representing the asynchronous request. /// </returns> public static Task DeleteAsync(this IWebhookClient client, IRestRequestOptions options = null, CancellationToken cancellationToken = default) { return(client.RestClient.DeleteWebhookAsync(client.Id, client.Token, options, cancellationToken)); }
/// <summary> /// Modifies this webhook using the provided action. /// </summary> /// <param name="client"> The webhook client. </param> /// <param name="action"> The action specifying what properties to modify. </param> /// <param name="options"> The optional request options. </param> /// <param name="cancellationToken"> The cancellation token to observe. </param> /// <returns> /// A <see cref="Task{TResult}"/> representing the asynchronous request /// that wraps the returned <see cref="IWebhook"/>. /// </returns> public static Task <IWebhook> ModifyAsync(this IWebhookClient client, Action <ModifyWebhookActionProperties> action, IRestRequestOptions options = null, CancellationToken cancellationToken = default) { return(client.RestClient.ModifyWebhookAsync(client.Id, action, client.Token, options, cancellationToken)); }
public AppHost(SendAgentDbContext context, IWebhookClient webhookClient) { _context = context; _webhookClient = webhookClient; }
/// <summary> /// Deletes a message sent by this webhook. /// </summary> /// <param name="client"> The webhook client. </param> /// <param name="messageId"> The ID of the message to modify. </param> /// <param name="options"> The optional request options. </param> /// <returns> /// A <see cref="Task"/> representing the asynchronous request. /// </returns> public static Task DeleteMessageAsync(this IWebhookClient client, Snowflake messageId, IRestRequestOptions options = null) => client.RestClient.DeleteWebhookMessageAsync(client.Id, client.Token, messageId, options);
/// <summary> /// Modifies a message sent by this webhook. /// </summary> /// <param name="client"> The webhook client. </param> /// <param name="messageId"> The ID of the message to modify. </param> /// <param name="action"> The action specifying what properties to modify. </param> /// <param name="options"> The optional request options. </param> /// <returns> /// A <see cref="Task{TResult}"/> representing the asynchronous request /// that wraps the updated <see cref="IUserMessage"/>. /// </returns> public static Task <IUserMessage> ModifyMessageAsync(this IWebhookClient client, Snowflake messageId, Action <ModifyWebhookMessageActionProperties> action, IRestRequestOptions options = null) => client.RestClient.ModifyWebhookMessageAsync(client.Id, client.Token, messageId, action, options);
/// <summary> /// Fetch a message sent by this webhook. /// </summary> /// <param name="client"> The webhook client. </param> /// <param name="messageId"> The ID of the message to fetch. </param> /// <param name="options"> The optional request options. </param> /// <returns> /// A <see cref="Task"/> representing the asynchronous request. /// </returns> public static Task <IUserMessage> FetchMessageAsync(this IWebhookClient client, Snowflake messageId, IRestRequestOptions options = null) => client.RestClient.FetchWebhookMessageAsync(client.Id, client.Token, messageId, options);
/// <summary> /// Executes this webhook, i.e. sends a message from it. /// </summary> /// <param name="client"> The webhook client. </param> /// <param name="message"> The message to send. </param> /// <param name="wait"> Whether the API should return a message. </param> /// <param name="options"> The optional request options. </param> /// <returns> /// A <see cref="Task{TResult}"/> representing the asynchronous request /// that wraps the returned <see cref="IUserMessage"/> if <paramref name="wait"/> is <see langword="true"/>. /// </returns> public static Task <IUserMessage> ExecuteAsync(this IWebhookClient client, LocalWebhookMessage message, bool wait = false, IRestRequestOptions options = null) => client.RestClient.ExecuteWebhookAsync(client.Id, client.Token, message, wait, options);
/// <summary> /// Deletes this webhook. /// </summary> /// <param name="client"> The webhook client. </param> /// <param name="options"> The optional request options. </param> /// <returns> /// A <see cref="Task"/> representing the asynchronous request. /// </returns> public static Task DeleteAsync(this IWebhookClient client, IRestRequestOptions options = null) => client.RestClient.DeleteWebhookAsync(client.Id, client.Token, options);
/// <summary> /// Modifies this webhook using the provided action. /// </summary> /// <param name="client"> The webhook client. </param> /// <param name="action"> The action specifying what properties to modify. </param> /// <param name="options"> The optional request options. </param> /// <returns> /// A <see cref="Task{TResult}"/> representing the asynchronous request /// that wraps the returned <see cref="IWebhook"/>. /// </returns> public static Task <IWebhook> ModifyAsync(this IWebhookClient client, Action <ModifyWebhookActionProperties> action, IRestRequestOptions options = null) => client.RestClient.ModifyWebhookAsync(client.Id, action, client.Token, options);
/// <summary> /// Fetches this webhook.. /// </summary> /// <param name="client"> The webhook client. </param> /// <param name="options"> The optional request options. </param> /// <returns> /// A <see cref="Task{TResult}"/> representing the asynchronous request /// that wraps the returned <see cref="IWebhook"/>. /// </returns> public static Task <IWebhook> FetchAsync(this IWebhookClient client, IRestRequestOptions options = null) => client.RestClient.FetchWebhookAsync(client.Id, client.Token, options);
public NewCommandPostMessageHandler(IWebhookClient webhookClient, ApplicationDbContext dbContext) { _webhookClient = webhookClient; _dbContext = dbContext; }