/// <summary> Loads the avatar of this user. </summary>
        public IEnumerator GetAvatar(DiscordTextureCallback callback)
        {
            if (avatarState == TextureState.Unloaded)
            {
                avatarState = TextureState.Loading;
                WWW www = new WWW("https://cdn.discordapp.com/avatars/" + ID + "/" + avatarID + ".jpg");
                yield return(www);

                Texture2D result = www.texture;

                if (result == null)
                {
                    avatarState = TextureState.NoTexture;
                    yield break;
                }

                avatar      = www.texture;
                avatarState = TextureState.Loaded;
                client.unityInvoker.Enqueue(() => callback(client, avatar, new DiscordError()));
            }
        }
Exemple #2
0
        /// <summary> Loads the splash for this server. </summary>
        public IEnumerator LoadSplash(DiscordTextureCallback callback)
        {
            if (splashState == TextureState.Unloaded)
            {
                splashState = TextureState.Loading;
                WWW www = new WWW("https://cdn.discordapp.com/splashes/" + ID + "/" + splashID + ".jpg");
                yield return(www);

                Texture2D result = www.texture;

                if (result == null)
                {
                    splashState = TextureState.NoTexture;
                    yield break;
                }

                splash      = www.texture;
                splashState = TextureState.Loaded;
                client.unityInvoker.Enqueue(() => callback(client, splash, new DiscordError()));
            }
        }
Exemple #3
0
        /// <summary> Loads the icon for this server. </summary>
        public IEnumerator LoadIcon(DiscordTextureCallback callback)
        {
            if (iconState == TextureState.Unloaded)
            {
                iconState = TextureState.Loading;
                WWW www = new WWW("https://cdn.discordapp.com/icons/" + ID + "/" + iconID + ".jpg");
                yield return(www);

                Texture2D result = www.texture;

                if (result == null)
                {
                    iconState = TextureState.NoTexture;
                    client.unityInvoker.Enqueue(() => callback(client, null, new DiscordError("Failed to load texture.")));
                    yield break;
                }

                icon      = www.texture;
                iconState = TextureState.Loaded;
                client.unityInvoker.Enqueue(() => callback(client, icon, new DiscordError()));
            }
        }
Exemple #4
0
        public IEnumerator GetEmoji(DiscordTextureCallback callback)
        {
            if (emojiState == TextureState.Unloaded)
            {
                emojiState = TextureState.Loading;
                Debug.Log("https://cdn.discordapp.com/emojis/" + ID + ".png");
                WWW www = new WWW("https://cdn.discordapp.com/emojis/" + ID + ".png");
                yield return(www);

                Texture2D result = www.texture;

                if (result == null)
                {
                    emojiState = TextureState.NoTexture;
                    yield break;
                }

                emoji      = www.texture;
                emojiState = TextureState.Loaded;
                client.unityInvoker.Enqueue(() => callback(client, emoji, new DiscordError()));
            }
        }