private async Task <ICustomEmoji> GetEmojiAsync(string value) { if (LocalCustomEmoji.TryParse(value, out var emoji)) { return(Context.Guild !.Emojis.FirstOrDefault(x => x.Value.Id == emoji.Id).Value ?? (ICustomEmoji)await Context.Guild !.GetEmojiAsync(emoji.Id)); } if (Snowflake.TryParse(value, out var emojiId)) { return(Context.Guild !.Emojis.FirstOrDefault(x => x.Value.Id == emojiId).Value ?? (ICustomEmoji)await Context.Guild !.GetEmojiAsync(emojiId)); } value = value.Replace(" ", "_"); return(Context.Guild !.Emojis.FirstOrDefault(e => string.Equals(e.Value.Name, value, StringComparison.OrdinalIgnoreCase)).Value); }
private void EmojiWindow_Loaded(object sender, RoutedEventArgs e) { var window = mmApp.Model.Window; window.ButtonEmoji.Focus(); WindowUtilities.DoEvents(); var pos = window.ButtonEmoji.TransformToAncestor(window) .Transform(new Point(0, 0)); // hard code so it works both with mouse and keyboard Left = window.Left + pos.X - 10; Top = window.Top + pos.Y + window.ButtonEmoji.Height; TextSearchText.Focus(); ListEmojis.SelectedItem = Emojis.FirstOrDefault(kv => kv.Key == ":smile:"); }