public async Task WhoIs(CommandContext ctx, [Description("Пользователь"), RemainingText] DiscordUser user) { if (user.Id == 261137595965243393) { Random random = new Random(); int value = random.Next(100); if (value < 30) { await ctx.RespondAsync("https://media.giphy.com/media/eKrgVyZ7zLvJrgZNZn/giphy.gif"); return; } } await ctx.TriggerTypingAsync(); try { DiscordMember member = null; try { member = await ctx.Guild.GetMemberAsync(user.Id); } catch (NotFoundException) { // is not a member of the guild } //Сбор информации в переменные var ban = GetBansInfo(user.Id); var warnings = WarnSQL.GetForUser(user.Id).Count; var reports = ReportSQL.GetForUser(user.Id); var webUser = WebUser.GetByDiscordId(user.Id); var voiceTime = VoiceListener.GetUpdatedVoiceTime(user.Id); //Создание эмбеда var embed = new DiscordEmbedBuilder(); embed.WithAuthor($"{user.Username}#{user.Discriminator}", iconUrl: user.AvatarUrl); embed.WithThumbnail(user.AvatarUrl); //Статус на сервере if (ban != null) { embed.WithColor(new DiscordColor("#c0392b")); embed.WithDescription($"Забанен до {ban}."); } else if (member == null) { embed.WithColor(new DiscordColor("#e67e22")); embed.WithDescription("Не является участником."); } else { embed.WithColor(new DiscordColor("#27ae60")); embed.WithDescription("Участник сервера."); } //1 Row - ID, Username embed.AddFieldOrDefault("ID", user.Id.ToString(), true); if (member != null) { embed.AddFieldOrDefault("Имя на сервере", member.Mention, true); } embed.NewInlineRow(); //2 Row - Creation and join dates, VoiceTime embed.AddFieldOrDefault("Создан", user.CreationTimestamp.ToString("HH:mm:ss \n dd.MM.yyyy"), true); if (member != null) { embed.AddFieldOrDefault("Присоединился", member.JoinedAt.ToString("HH:mm:ss \n dd.MM.yyyy"), true); } embed.AddFieldOrDefault("Время в каналах", $"{(voiceTime.Days * 24) + voiceTime.Hours}:{voiceTime.Minutes}", true); //3 Row - WebUser info if (webUser != null) { embed.AddFieldOrDefault("Привязка", "Да", true); embed.AddFieldOrEmpty("Страна", GetCountryFlag(webUser.LastIp), true); if (!string.IsNullOrEmpty(webUser.LastXbox)) { embed.AddFieldOrDefault("Xbox", webUser.LastXbox.ToString(), true); } else { embed.AddFieldOrDefault("Xbox", "Нет", true); } } embed.NewInlineRow(); //4 Row - Donate info embed.AddFieldOrReplace("Донат", GetDonationInfo(user.Id), "Нет", true); embed.AddFieldOrReplace("Подписка", GetSubscriptionInfo(user.Id), "Нет", true); embed.AddFieldOrReplace("Приватный корабль", GetPrivateShip(user.Id), "Нет", true); embed.NewInlineRow(); //5 Row - Reports info embed.AddFieldOrDefault("Предупреждения", $":pencil: {warnings}", true); embed.AddFieldOrDefault("Правила", GetCodexInfo(reports, member), true); embed.AddFieldOrDefault("Правила рейда", GetFleetCodexInfo(reports, member), true); embed.AddFieldOrDefault("Мут", $"{GetMutesInfo(reports)}", true); embed.AddFieldOrDefault("Голосовой мут", $"{GetVoiceMutesInfo(reports)}", true); embed.NewInlineRow(); //6 Row - Note if (Note.Notes.ContainsKey(user.Id)) { embed.AddFieldOrDefault("Заметка", Note.Notes[user.Id].Content); } embed.WithFooter("(*) Не принял после разблокировки"); var message = await ctx.RespondAsync(embed : embed.Build()); //Реакция на вывод сообщения с предупреждениями if (warnings > 0) { var interactivity = ctx.Client.GetInteractivity(); var emoji = DiscordEmoji.FromName(ctx.Client, ":pencil:"); await message.CreateReactionAsync(emoji); var em = await interactivity.WaitForReactionAsync(xe => xe.Emoji == emoji, message, ctx.User, TimeSpan.FromSeconds(60)); if (!em.TimedOut) { await ctx.TriggerTypingAsync(); var command = $"whois wl {user.Id}"; var cmds = ctx.CommandsNext; // Ищем команду и извлекаем параметры. var cmd = cmds.FindCommand(command, out var customArgs); // Создаем фейковый контекст команды. var fakeContext = cmds.CreateFakeContext(ctx.Member, ctx.Channel, command, ctx.Prefix, cmd, customArgs); // Выполняем команду за пользователя. await cmds.ExecuteCommandAsync(fakeContext); } else { await message.DeleteAllReactionsAsync(); } } } catch (NotFoundException) { await ctx.RespondAsync($"{Bot.BotSettings.ErrorEmoji} Пользователь не найден."); } }
public async Task EventCheck(CommandContext ctx, DiscordMessage message, DiscordEmoji reaction) { await ctx.Message.DeleteAsync(); await ctx.TriggerTypingAsync(); var allReactions = new List <DiscordUser>(); var reactions = await message.GetReactionsAsync(reaction); while (reactions.Count() != 0) { allReactions.AddRange(reactions); reactions = await message.GetReactionsAsync(reaction, after : reactions.Last().Id); } var allReactionsMembers = await Task.WhenAll(allReactions.Select(async x => { try { await Task.Delay(400); return(await ctx.Guild.GetMemberAsync(x.Id)); } catch { } return(null); })); var reactionsList = allReactionsMembers.OrderByDescending(x => x.CreationTimestamp).Select(x => $"C: **{x.CreationTimestamp:dd.MM.yyyy}** J: **{x.JoinedAt:dd.MM.yyyy}** V: **{VoiceListener.GetUpdatedVoiceTime(x.Id)}** \n" + $"{x.Username} ({x.Id})").ToList(); var members_pagination = Utility.GeneratePagesInEmbeds(reactionsList, $"Список проголосовавших (По дате создания аккаунта)."); var interactivity = ctx.Client.GetInteractivity(); if (members_pagination.Count() > 1) { await interactivity.SendPaginatedMessageAsync(await ctx.Member.CreateDmChannelAsync(), ctx.User, members_pagination, timeoutoverride : TimeSpan.FromMinutes(5)); } else { await ctx.Member.SendMessageAsync(embed : members_pagination.First().Embed); } }