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

net.dv8tion.jda.api.entities.templates.Template 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.entities.templates;

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.exceptions.InsufficientPermissionException;
import net.dv8tion.jda.api.managers.TemplateManager;
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.Route;
import net.dv8tion.jda.internal.JDAImpl;
import net.dv8tion.jda.internal.managers.TemplateManagerImpl;
import net.dv8tion.jda.internal.requests.RestActionImpl;
import net.dv8tion.jda.internal.utils.Checks;
import net.dv8tion.jda.internal.utils.EntityString;

import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.time.OffsetDateTime;

/**
 * Representation of a Discord Guild Template
 * 
This class is immutable. * * @since 4.3.0 * * @see #resolve(JDA, String) * @see net.dv8tion.jda.api.entities.Guild#retrieveTemplates() Guild.retrieveTemplates() */ public class Template { private final JDAImpl api; private final String code; private final String name; private final String description; private final int uses; private final User creator; private final OffsetDateTime createdAt; private final OffsetDateTime updatedAt; private final TemplateGuild guild; private final boolean synced; public Template(final JDAImpl api, final String code, final String name, final String description, final int uses, final User creator, final OffsetDateTime createdAt, final OffsetDateTime updatedAt, final TemplateGuild guild, final boolean synced) { this.api = api; this.code = code; this.name = name; this.description = description; this.uses = uses; this.creator = creator; this.createdAt = createdAt; this.updatedAt = updatedAt; this.guild = guild; this.synced = synced; } /** * Retrieves a new {@link net.dv8tion.jda.api.entities.templates.Template Template} instance for the given template code. * *

Possible {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} include: *

    *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_GUILD_TEMPLATE Unknown Guild Template} *
    The template doesn't exist.
  • *
* * @param api * The JDA instance * @param code * A valid template code * * @throws java.lang.IllegalArgumentException *
    *
  • If the provided code is null or empty
  • *
  • If the provided code contains a whitespace
  • *
  • If the provided JDA object is null
  • *
* * @return {@link net.dv8tion.jda.api.requests.RestAction RestAction} - Type: {@link net.dv8tion.jda.api.entities.templates.Template Template} *
The Template object */ @Nonnull public static RestAction