public Task SetSteamId([Summary("User whos get new infoes")] SocketUser user, [Summary("User steam profile url")] string url) { if (IsValidChannel(Context.Guild.Id, Context.Channel.Id)) { ulong steamId = Task.Run(async() => { return(await _dota.GetSteamIdAsync(url)); }).Result; if (steamId == 0) { return(ReplyAsync("SteamId не найден")); } var userDb = _db.UserInfos.FirstOrDefault(u => u.Id == user.Id); if (userDb != null) { userDb.SteamId = steamId; } else { _db.UserInfos.Add(new UserInfo() { Id = user.Id, SteamId = steamId }); } _db.SaveChanges(); ReplyAsync("Пользователь сохраннен"); } return(Task.CompletedTask); }
public async Task GetDotaInfoes([Summary("Steam URL of the user whose game to get")] string url) { ulong steamId = Task.Run(async() => { return(await _dota.GetSteamIdAsync(url)); }).Result; if (IsValidChannel(Context.Guild.Id, Context.Channel.Id)) { if (steamId > 0) { var res = await _dota.GetDotaAsync(steamId); res.PlayerId = steamId; using (MemoryStream imageStream = new MemoryStream()) { _draw.DrawImage(res, imageStream); imageStream.Position = 0; await Context.Channel.SendFileAsync(imageStream, "Test.jpeg"); } } else { _ = _logger.LogMessage("Нет подходящего steamId"); } } }