Class Webhook

    • Constructor Detail

      • Webhook

        public Webhook​(GatewayDiscordClient gateway,
                       discord4j.discordjson.json.WebhookData data)
        Constructs a Webhook with an associated GatewayDiscordClient and Discord data.
        Parameters:
        gateway - The GatewayDiscordClient associated to this object, must be non-null.
        data - The raw data as represented by Discord, must be non-null.
    • Method Detail

      • getId

        public Snowflake getId()
        Description copied from interface: Entity
        Gets the Snowflake that uniquely identifies this entity.
        Specified by:
        getId in interface Entity
        Returns:
        The Snowflake that uniquely identifies this entity.
      • getData

        public discord4j.discordjson.json.WebhookData getData()
        Gets the data of the webhook.
        Returns:
        The data of the webhook.
      • getType

        public Webhook.Type getType()
        Gets the type of the webhook.
        Returns:
        The type of the webhook.
      • getGuildId

        public Snowflake getGuildId()
        Gets the ID of the guild this webhook is associated to.
        Returns:
        The ID of the guild this webhook is associated to.
      • getGuild

        public Mono<Guild> getGuild()
        Requests to retrieve the guild this webhook is associated to.
        Returns:
        A Mono where, upon successful completion, emits the guild this webhook is associated to. If an error is received, it is emitted through the Mono.
      • getGuild

        public Mono<Guild> getGuild​(EntityRetrievalStrategy retrievalStrategy)
        Requests to retrieve the guild this webhook is associated to, using the given retrieval strategy.
        Parameters:
        retrievalStrategy - the strategy to use to get the guild
        Returns:
        A Mono where, upon successful completion, emits the guild this webhook is associated to. If an error is received, it is emitted through the Mono.
      • getChannelId

        public Snowflake getChannelId()
        Gets the ID of the channel this webhook is associated to.
        Returns:
        The ID of the channel this webhook is associated to.
      • getChannel

        public Mono<GuildMessageChannel> getChannel()
        Requests to retrieve the channel this webhook is associated to.
        Returns:
        A Mono where, upon successful completion, emits the channel this webhook is associated to. If an error is received, it is emitted through the Mono.
      • getChannel

        public Mono<GuildMessageChannel> getChannel​(EntityRetrievalStrategy retrievalStrategy)
        Requests to retrieve the channel this webhook is associated to, using the given retrieval strategy.
        Parameters:
        retrievalStrategy - the strategy to use to get the channel
        Returns:
        A Mono where, upon successful completion, emits the channel this webhook is associated to. If an error is received, it is emitted through the Mono.
      • getCreator

        public Optional<User> getCreator()
        Requests to retrieve the user this webhook was created by, if present. Returns no creator if the webhook was retrieved using a token.
        Returns:
        An Optional with the user this webhook was created by, if present.
      • getName

        public Optional<String> getName()
        Gets the default name of the webhook.
        Returns:
        The default name of the webhook.
      • getAvatar

        public Optional<String> getAvatar()
        Gets the avatar of this webhook, if present.
        Returns:
        The avatar of this webhook, if present.
      • getToken

        public Optional<String> getToken()
        Gets the secure token of this webhook. The token is present for Webhook.Type.INCOMING webhooks.
        Returns:
        The secure token of this webhook.
      • getApplicationId

        public Optional<Snowflake> getApplicationId()
        Gets the bot/OAuth2 application ID that created this webhook.
        Returns:
        The bot/OAuth2 application ID that created this webhook.
      • getSourceGuildId

        public Optional<Snowflake> getSourceGuildId()
        Gets the guild id of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.
        Returns:
        The guild id of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.
      • getSourceGuildName

        public Optional<String> getSourceGuildName()
        Gets the guild name of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.
        Returns:
        The guild name of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.
      • getSourceChannelId

        public Optional<Snowflake> getSourceChannelId()
        Gets the id of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.
        Returns:
        The id of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.
      • getSourceChannelName

        public Optional<String> getSourceChannelName()
        Gets the name of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.
        Returns:
        The name of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.
      • delete

        public Mono<Void> delete()
        Requests to delete this webhook. Requires the MANAGE_WEBHOOKS permission.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating the webhook has been deleted. If an error is received, it is emitted through the Mono.
      • delete

        public Mono<Void> delete​(@Nullable
                                 String reason)
        Requests to delete this webhook while optionally specifying a reason. Requires the MANAGE_WEBHOOKS permission.
        Parameters:
        reason - The reason, if present.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating the webhook has been deleted. If an error is received, it is emitted through the Mono.
      • deleteWithToken

        public Mono<Void> deleteWithToken()
        Requests to delete this webhook.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating the webhook has been deleted. If an error is received, it is emitted through the Mono.
      • edit

        public discord4j.core.spec.WebhookEditMono edit()
        Requests to edit this webhook. Properties specifying how to edit this webhook can be set via the withXxx methods of the returned WebhookEditMono. Requires the MANAGE_WEBHOOKS permission.
        Returns:
        A WebhookEditMono where, upon successful completion, emits the edited Webhook. If an error is received, it is emitted through the WebhookEditMono.
      • edit

        public Mono<Webhook> edit​(discord4j.core.spec.WebhookEditSpec spec)
        Requests to edit this webhook. Requires the MANAGE_WEBHOOKS permission.
        Parameters:
        spec - an immutable object that specifies how to edit this webhook
        Returns:
        A Mono where, upon successful completion, emits the edited Webhook. If an error is received, it is emitted through the Mono.
      • editWithToken

        public discord4j.core.spec.WebhookEditWithTokenMono editWithToken()
        Requests to edit this webhook. Properties specifying how to edit this webhook can be set via the withXxx methods of the returned WebhookEditWithTokenMono. Does not require the MANAGE_WEBHOOKS permission.
        Returns:
        A WebhookEditWithTokenMono where, upon successful completion, emits the edited Webhook. If an error is received, it is emitted through the WebhookEditWithTokenMono.
      • editWithToken

        public Mono<Webhook> editWithToken​(discord4j.core.spec.WebhookEditWithTokenSpec spec)
        Requests to edit this webhook. Does not require the MANAGE_WEBHOOKS permission.
        Parameters:
        spec - an immutable object that specifies how to edit this webhook
        Returns:
        A Mono where, upon successful completion, emits the edited Webhook. If an error is received, it is emitted through the Mono.
      • execute

        public discord4j.core.spec.WebhookExecuteMono execute()
        Executes this webhook. Properties specifying how to execute this webhook, including whether to wait for confirmation that the message was created, can be set via the withXxx methods of the returned WebhookExecuteMono.
        Returns:
        A WebhookExecuteMono where, upon successful webhook execution, emits a Message if withWaitForMessage(true). If the message fails to save, an error is emitted through the WebhookExecuteMono only if withWaitForMessage(true).
      • execute

        public Mono<Void> execute​(discord4j.core.spec.WebhookExecuteSpec spec)
        Executes this webhook without waiting for a confirmation that a message was created.
        Parameters:
        spec - an immutable object that specifies how to execute this webhook
        Returns:
        A Mono where, upon successful webhook execution, completes. If the message fails to save, an error IS NOT emitted through the Mono.
      • execute

        @Deprecated
        public Mono<Message> execute​(boolean wait,
                                     Consumer<? super LegacyWebhookExecuteSpec> spec)
        Deprecated.
        use execute(boolean, WebhookExecuteSpec) which offers an immutable approach to build specs
        Executes this webhook.
        Parameters:
        wait - True to specify to wait for server confirmation that the message was saved or there was an error saving the message.
        spec - A Consumer that provides a "blank" LegacyWebhookExecuteSpec to be operated on.
        Returns:
        A Mono where, upon successful webhook execution, emits a Message if wait = true. If the message fails to save, an error is emitted through the Mono only if wait = true.
      • execute

        public Mono<Message> execute​(boolean wait,
                                     discord4j.core.spec.WebhookExecuteSpec spec)
        Executes this webhook.
        Parameters:
        wait - True to specify to wait for server confirmation that the message was saved or there was an error saving the message.
        spec - an immutable object that specifies how to execute this webhook
        Returns:
        A Mono where, upon successful webhook execution, emits a Message if wait = true. If the message fails to save, an error is emitted through the Mono only if wait = true.
      • executeAndWait

        public Mono<Message> executeAndWait​(discord4j.core.spec.WebhookExecuteSpec spec)
        Executes this webhook and waits for server confirmation for the message to save.
        Parameters:
        spec - an immutable object that specifies how to execute this webhook
        Returns:
        A Mono where, upon successful webhook execution, emits a Message. If the message fails to save, an error is emitted through the Mono.
      • getMessage

        public Mono<Message> getMessage​(Snowflake messageId)
        Executes this webhook to get a message.
        Parameters:
        messageId - The ID of the message to get
        Returns:
        A Mono where, upon successful webhook execution, emits a Message. If the message get fails, an error is emitted through the Mono.
      • editMessage

        public discord4j.core.spec.WebhookMessageEditMono editMessage​(Snowflake messageId)
        Executes this webhook to edit a message. Properties specifying how to execute this webhook, including the ID of the message being edited, can be set via the withXxx methods of the returned WebhookMessageEditMono.
        Parameters:
        messageId - The ID of the message to edit
        Returns:
        A WebhookMessageEditMono where, upon successful webhook execution, emits a Message. If the message edit fails, an error is emitted through the WebhookMessageEditMono.
      • editMessage

        public Mono<Message> editMessage​(Snowflake messageId,
                                         discord4j.core.spec.WebhookMessageEditSpec spec)
        Executes this webhook to edit a message.
        Parameters:
        messageId - The ID of the message to edit
        spec - an immutable object that specifies how to edit the message
        Returns:
        A Mono where, upon successful webhook execution, emits a Message. If the message edit fails, an error is emitted through the Mono.
      • deleteMessage

        public Mono<Void> deleteMessage​(Snowflake messageId)
        Executes this webhook to delete a message.
        Parameters:
        messageId - The ID of the message to delete
        Returns:
        A Mono where, upon successful webhook execution, emits nothing; indicating the message has been deleted. If the message delete fails, an error is emitted through the Mono.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object