public async void SyncPress(object sender, RoutedEventArgs e) { ChangeMainWindowState(CustomWindowStates.Syncing); string? _finishedAt = null; string? _startedFrom = null; FolderTile?myFt = null; string channelID; if (sender is MenuItem mi) { channelID = mi.CommandParameter.ToString(); myFt = Tiles[channelID]; } else if (sender is FolderTile ft) { channelID = ft.MyConfig.ChannelId; myFt = ft; } else { MessageBox.Show("Something went wrong"); ChangeMainWindowState(CustomWindowStates.AfterSyncing); return; } _bgImage.Source = new BitmapImage(new Uri(myFt.MyConfig.IconUrl)); ChannelConfig.Values thisConfig = chConfig.list[channelID]; string cancelContent = $"Syncing #{thisConfig.ChannelName.Split(" > ")[^1]}...\nClick here to pause/cancel";
public async Task <int> SearchMediaInChannel(string token, ChannelConfig.Values cfg) { JToken response; string route; if (cfg.LastMsgChecked == null) { route = $"guilds/{cfg.GuildId}/messages/search?channel_id={cfg.ChannelId}&has=file&has=image&has=embed&has=link&include_nsfw=true"; } else { //string minDate = ((DateTimeOffset)cfg.LastMsgChecked).ToSnowflake(); string minDate = cfg.LastMsgChecked; route = $"guilds/{cfg.GuildId}/messages/search?channel_id={cfg.ChannelId}&has=file&has=image&has=embed&has=link&include_nsfw=true&min_id={minDate}"; } response = await GetApiResponseAsync(token, route); // there doesn't seem to be any stuck pings when using snowflakes rather than timestamps return((int)response["total_results"]); }