net.dv8tion.jda.api.managers.GuildStickerManager Maven / Gradle / Ivy
Show all versions of JDA Show documentation
/*
* 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.sticker.GuildSticker;
import net.dv8tion.jda.api.entities.sticker.StickerSnowflake;
import net.dv8tion.jda.internal.utils.Checks;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Collection;
/**
* Manager providing functionality to update one or more fields for {@link GuildSticker}.
*
* Example
*
{@code
* manager.setName("catDance")
* .setDescription("Cat dancing")
* .queue();
* manager.reset(GuildStickerManager.NAME | GuildStickerManager.TAGS)
* .setName("dogDance")
* .setTags("dancing", "dog")
* .queue();
* }
*
* @see GuildSticker#getManager()
* @see Guild#editSticker(StickerSnowflake)
*/
public interface GuildStickerManager extends Manager
{
/** Used to reset name field */
long NAME = 1;
/** Used to reset description field */
long DESCRIPTION = 1 << 1;
/** Used to reset tags field */
long TAGS = 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(GuildStickerManager.NAME | GuildStickerManager.TAGS);}
*
* Flag Constants:
*
* - {@link #NAME}
* - {@link #DESCRIPTION}
* - {@link #TAGS}
*
*
* @param fields
* Integer value containing the flags to reset.
*
* @return GuildStickerManager for chaining convenience
*/
@Nonnull
@Override
@CheckReturnValue
GuildStickerManager reset(long fields);
/**
* Resets the fields specified by the provided bit-flag patterns.
*
Example: {@code manager.reset(GuildStickerManager.NAME, GuildStickerManager.TAGS);}
*
* Flag Constants:
*
* - {@link #NAME}
* - {@link #DESCRIPTION}
* - {@link #TAGS}
*
*
* @param fields
* Integer value containing the flags to reset.
*
* @return GuildStickerManager for chaining convenience
*/
@Nonnull
@Override
@CheckReturnValue
GuildStickerManager reset(long... fields);
/**
* The {@link Guild} this Manager's {@link GuildSticker} is in.
*
* This is null if {@link GuildSticker#getManager()} is used on a sticker with an uncached guild.
*
* @return The {@link Guild Guild}, or null if not present.
*
* @see #getGuildId()
*/
@Nullable
Guild getGuild();
/**
* The ID of the guild this sticker belongs to.
*
* @return The guild id
*/
long getGuildIdLong();
/**
* The ID of the guild this sticker belongs to.
*
* @return The guild id
*/
@Nonnull
default String getGuildId()
{
return Long.toUnsignedString(getGuildIdLong());
}
/**
* Sets the name of the sticker.
*
*
A sticker name must be between 2-30 characters long!
*
*
Example: {@code catDance} or {@code dogWave}
*
* @param name
* The new name for the sticker (2-30 characters)
*
* @throws IllegalArgumentException
* If the provided name is {@code null} or not between 2-30 characters long
*
* @return GuildStickerManager for chaining convenience
*/
@Nonnull
@CheckReturnValue
GuildStickerManager setName(@Nonnull String name);
/**
* Sets the description of the sticker.
*
*
A sticker description must be between 2-100 characters long!
*
* @param description
* The new description for the sticker (2-100 characters)
*
* @throws IllegalArgumentException
* If the provided description is {@code null} or not between 2-100 characters long
*
* @return GuildStickerManager for chaining convenience
*/
@Nonnull
@CheckReturnValue
GuildStickerManager setDescription(@Nonnull String description);
/**
* Sets the tags of the sticker.
*
These are used for auto-complete when sending a message in the client, and for the sticker picker menu.
*
*
The combined list of sticker tags must at most be 200 characters long!
*
*
Example: {@code catDance} or {@code dogWave}
*
* @param tags
* The new tags for the sticker (up to 200 characters)
*
* @throws IllegalArgumentException
*
* - If {@code tags} is {@code null}
* - If {@code tags} is empty
* - If {@code tags} contains {@code null} or empty strings
* - If the concatenated tags are more than 200 characters long (including commas between tags)
*
*
* @return GuildStickerManager for chaining convenience
*/
@Nonnull
@CheckReturnValue
GuildStickerManager setTags(@Nonnull Collection tags);
/**
* Sets the tags of the sticker.
*
These are used for auto-complete when sending a message in the client, and for the sticker picker menu.
*
* The combined list of sticker tags must at most be 200 characters long!
*
*
Example: {@code catDance} or {@code dogWave}
*
* @param tags
* The new tags for the sticker (up to 200 characters)
*
* @throws IllegalArgumentException
*
* - If {@code tags} is {@code null}
* - If {@code tags} is empty
* - If {@code tags} contains {@code null} or empty strings
* - If the concatenated tags are more than 200 characters long (including commas between tags)
*
*
* @return GuildStickerManager for chaining convenience
*/
@Nonnull
@CheckReturnValue
default GuildStickerManager setTags(@Nonnull String... tags)
{
Checks.noneNull(tags, "Tags");
return setTags(Arrays.asList(tags));
}
}