All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.dv8tion.jda.api.managers.WebhookManager Maven / Gradle / Ivy

Go to download

Java wrapper for the popular chat & VOIP service: Discord https://discord.com

There is a newer version: 5.1.0
Show newest version
/*
 * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.dv8tion.jda.api.managers;

import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Icon;
import net.dv8tion.jda.api.entities.Webhook;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.entities.channel.unions.IWebhookContainerUnion;

import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * Manager providing functionality to update one or more fields for a {@link net.dv8tion.jda.api.entities.Webhook Webhook}.
 *
 * 

Example *

{@code
 * manager.setName("GitHub Webhook")
 *        .setChannel(channel)
 *        .queue();
 * manager.reset(WebhookManager.NAME | WebhookManager.AVATAR)
 *        .setName("Meme Feed")
 *        .setAvatar(null)
 *        .queue();
 * }
* * @see net.dv8tion.jda.api.entities.Webhook#getManager() */ public interface WebhookManager extends Manager { /** Used to reset the name field */ long NAME = 1; /** Used to reset the channel field */ long CHANNEL = 1 << 1; /** Used to reset the avatar field */ long AVATAR = 1 << 2; /** * Resets the fields specified by the provided bit-flag pattern. * You can specify a combination by using a bitwise OR concat of the flag constants. *
Example: {@code manager.reset(WebhookManager.CHANNEL | WebhookManager.NAME);} * *

Flag Constants: *

    *
  • {@link #NAME}
  • *
  • {@link #AVATAR}
  • *
  • {@link #CHANNEL}
  • *
* * @param fields * Integer value containing the flags to reset. * * @return WebhookManager for chaining convenience */ @Nonnull @Override WebhookManager reset(long fields); /** * Resets the fields specified by the provided bit-flag patterns. *
Example: {@code manager.reset(WebhookManager.CHANNEL, WebhookManager.NAME);} * *

Flag Constants: *

    *
  • {@link #NAME}
  • *
  • {@link #AVATAR}
  • *
  • {@link #CHANNEL}
  • *
* * @param fields * Integer values containing the flags to reset. * * @return WebhookManager for chaining convenience */ @Nonnull @Override WebhookManager reset(long... fields); /** * The target {@link net.dv8tion.jda.api.entities.Webhook Webhook} * that will be modified by this manager * * @return The target {@link net.dv8tion.jda.api.entities.Webhook Webhook} */ @Nonnull Webhook getWebhook(); /** * The {@link net.dv8tion.jda.api.entities.channel.attribute.IWebhookContainer channel} that this Manager's * {@link net.dv8tion.jda.api.entities.Webhook Webhook} is in. *
This is logically the same as calling {@code getWebhook().getChannel()} * * @return The parent {@link net.dv8tion.jda.api.entities.channel.attribute.IWebhookContainer} instance. */ @Nonnull default IWebhookContainerUnion getChannel() { return getWebhook().getChannel(); } /** * The {@link net.dv8tion.jda.api.entities.Guild Guild} this Manager's * {@link net.dv8tion.jda.api.entities.Webhook Webhook} is in. *
This is logically the same as calling {@code getWebhook().getGuild()} * * @return The parent {@link net.dv8tion.jda.api.entities.Guild Guild} */ @Nonnull default Guild getGuild() { return getWebhook().getGuild(); } /** * Sets the default name of the selected {@link net.dv8tion.jda.api.entities.Webhook Webhook}. * *

A webhook name must not be {@code null} or blank! * * @param name * The new default name for the selected {@link net.dv8tion.jda.api.entities.Webhook Webhook} * * @throws IllegalArgumentException * If the provided name is {@code null} or blank * * @return WebhookManager for chaining convenience */ @Nonnull @CheckReturnValue WebhookManager setName(@Nonnull String name); /** * Sets the default avatar of the selected {@link net.dv8tion.jda.api.entities.Webhook Webhook}. * * @param icon * The new default avatar {@link net.dv8tion.jda.api.entities.Icon Icon} * for the selected {@link net.dv8tion.jda.api.entities.Webhook Webhook} * or {@code null} to reset * * @return WebhookManager for chaining convenience */ @Nonnull @CheckReturnValue WebhookManager setAvatar(@Nullable Icon icon); /** * Sets the {@link TextChannel TextChannel} of the selected {@link net.dv8tion.jda.api.entities.Webhook Webhook}. * *

A webhook channel must not be {@code null} and must be in the same {@link net.dv8tion.jda.api.entities.Guild Guild}! * * @param channel * The new {@link TextChannel TextChannel} * for the selected {@link net.dv8tion.jda.api.entities.Webhook Webhook} * * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException * If the currently logged in account does not have the Permission {@link net.dv8tion.jda.api.Permission#MANAGE_WEBHOOKS MANAGE_WEBHOOKS} * in the specified TextChannel * @throws IllegalArgumentException * If the provided channel is {@code null} or from a different Guild * * @return WebhookManager for chaining convenience */ @Nonnull @CheckReturnValue WebhookManager setChannel(@Nonnull TextChannel channel); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy