Example #1
0
        public static async Task <AniListUser?> GetUser(bool setSettings = true)
        {
            try {
                const string q    = @"
				{
                    Viewer {
                        id
                        name
						avatar {
							large
						}
                    }
				}"                ;
                var          data = await PostApi("https://graphql.anilist.co", $"&query={q}");

                if (!data.IsClean())
                {
                    return(null);
                }
                AniListRoot userData = JsonConvert.DeserializeObject <AniListRoot>(data);
                var         u        = userData.data.Viewer;
                var         user     = new AniListUser()
                {
                    id      = u.id,
                    name    = u.name,
                    picture = u.avatar.large,
                };
                if (setSettings)
                {
                    Settings.CurrentAniListUser = user;
                }
                App.SaveData();
                return(user);
            }
            catch (Exception _ex) {
                CloudStreamCore.error(_ex);
                return(null);
            }
        }
Example #2
0
 private async Task <IReadOnlyList <DiscordEmbedBuilder> > GetFavouritesUpdatesAsync(CombinedRecentUpdatesResponse response, AniListUser user,
                                                                                     CancellationToken cancellationToken = default)
 {