// Request user's avatar data. Sizes can be powers of 2 between 16 and 2048 static void FetchAvatar(Discord.ImageManager imageManager, Int64 userID) { imageManager.Fetch(Discord.ImageHandle.User(userID), (result, handle) => { { if (result == Discord.Result.Ok) { // You can also use GetTexture2D within Unity. // These return raw RGBA. var data = imageManager.GetData(handle); /*try * { * var ms = new MemoryStream(data); * Bitmap bitmap = new Bitmap(ms); * bitmap.Save(handle.Id + ".bmp"); * } * catch (Exception e) * { * Console.WriteLine(e); * }*/ Console.WriteLine("image updated {0} {1}", handle.Id, data.Length); } else { Console.WriteLine("image error {0}", handle.Id); } } }); }
// Request user's avatar data. Sizes can be powers of 2 between 16 and 2048 static void FetchAvatar(Discord.ImageManager imageManager, Int64 userID) { imageManager.Fetch(Discord.ImageHandle.User(userID), (result, handle) => { { if (result == Discord.Result.Ok) { // You can also use GetTexture2D within Unity. // These return raw RGBA. var data = imageManager.GetData(handle); Console.WriteLine("image updated {0} {1}", handle.Id, data.Length); } else { Console.WriteLine("image error {0}", handle.Id); } } }); }