Package net.dv8tion.jda.api.entities
Class Icon
java.lang.Object
net.dv8tion.jda.api.entities.Icon
Icon containing a base64 encoded jpeg/png/gif/gifv image.
Used to represent various base64 images in the Discord api.
Example:
Used to represent various base64 images in the Discord api.
Example:
AccountManager.setAvatar(Icon)
.- Since:
- 3.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Supported image types for the Discord API. -
Method Summary
Modifier and TypeMethodDescriptionstatic Icon
from
(byte[] data) Creates anIcon
with the specified image data.static Icon
from
(byte[] data, Icon.IconType type) Creates anIcon
with the specified image data.static Icon
static Icon
from
(File file, Icon.IconType type) static Icon
from
(InputStream stream) Creates anIcon
with the specifiedInputStream
.static Icon
from
(InputStream stream, Icon.IconType type) Creates anIcon
with the specifiedInputStream
.The base64 encoded data for this Icon
-
Method Details
-
getEncoding
The base64 encoded data for this Icon- Returns:
- String representation of the encoded data for this icon
-
from
Creates anIcon
with the specifiedFile
.
We here read the specified File and forward the retrieved byte data tofrom(byte[], IconType)
.- Parameters:
file
- An existing, not-null file.- Returns:
- An Icon instance representing the specified File
- Throws:
IllegalArgumentException
- if the provided file is null, does not exist, or has an unsupported extensionIOException
- if there is a problem while reading the file.
-
from
Creates anIcon
with the specifiedInputStream
.
We here read the specified InputStream and forward the retrieved byte data tofrom(byte[], IconType)
. This will useIcon.IconType.JPEG
but discord is capable for interpreting other types correctly either way.- Parameters:
stream
- A not-null InputStream.- Returns:
- An Icon instance representing the specified InputStream
- Throws:
IllegalArgumentException
- if the provided stream is nullIOException
- If the first byte cannot be read for any reason other than the end of the file, if the input stream has been closed, or if some other I/O error occurs.
-
from
Creates anIcon
with the specified image data. This will useIcon.IconType.JPEG
but discord is capable for interpreting other types correctly either way.- Parameters:
data
- not-null image data bytes.- Returns:
- An Icon instance representing the specified image data
- Throws:
IllegalArgumentException
- if the provided data is null
-
from
@Nonnull public static Icon from(@Nonnull File file, @Nonnull Icon.IconType type) throws IOException Creates anIcon
with the specifiedFile
.
We here read the specified File and forward the retrieved byte data tofrom(byte[], IconType)
.- Parameters:
file
- An existing, not-null file.type
- The type of image- Returns:
- An Icon instance representing the specified File
- Throws:
IllegalArgumentException
- if the provided file is either null or does not existIOException
- if there is a problem while reading the file.
-
from
@Nonnull public static Icon from(@Nonnull InputStream stream, @Nonnull Icon.IconType type) throws IOException Creates anIcon
with the specifiedInputStream
.
We here read the specified InputStream and forward the retrieved byte data tofrom(byte[], IconType)
.- Parameters:
stream
- A not-null InputStream.type
- The type of image- Returns:
- An Icon instance representing the specified InputStream
- Throws:
IllegalArgumentException
- if the provided stream is nullIOException
- If the first byte cannot be read for any reason other than the end of the file, if the input stream has been closed, or if some other I/O error occurs.
-
from
Creates anIcon
with the specified image data.- Parameters:
data
- not-null image data bytes.type
- The type of image- Returns:
- An Icon instance representing the specified image data
- Throws:
IllegalArgumentException
- if the provided data is null
-