public async Task TrackerAsync() { var id = Context.User.Id; var description = $"You are not registered! `c!register` to register."; var builder = new LocalEmbedBuilder() .WithTitle("Tracker template"); var player = ContrackerService.GetPlayer(discordId: id.ToString()); if (player != null) { var contracts = ContrackerService.Contracker.GetPlayerContracts(player); if (contracts.Count > 0) { description = string.Join("\n", contracts.Select(x => $"`{x.Contract.Name}` - {x.Contract.Primary.Description}\n" + $"\tPoints: {x.Contract.Primary.Points}")); } else { description = "`You have no active contracts!`"; } } await ReplyAsync(embed : builder .WithDescription(description) .WithColor(Color.Honeydew) .Build()).ConfigureAwait(true); }
public async Task RegisterAsync(int accountNumber = -1) { Snowflake id = Context.User.Id; var users = DUserService.GetAccounts(id).Result; string title; string description; var player = ContrackerService.GetPlayer(discordId: id.ToString()); if (player == null) { switch (users.Count) { case 0: title = "Fail"; description = "`No Steam accounts associated with your account.`\n" + "[Go here](https://www.quora.com/How-will-I-add-my-gaming-accounts-in-Discord) " + "to see how to link your Steam account. You may unlink your account once you register."; break; case 1: if (DUserService.IsVerified(id).Result) { try { title = "Success"; description = "`API request sent...`"; ContrackerService.Contracker.CreatePlayer(users.First(), id.ToString()); } catch (XmlException e) { title = "Fail"; description = "`An error has occured. Probably server's fault.`"; Console.WriteLine(e); } } else { title = "Fail"; description = "`Your Steam account is not verified.`\n" + "[Go here](https://www.reddit.com/r/discordapp/comments/6elfxl/its_now_possible_to_have_a_verified_steam_account/) " + "to see how to verify your Steam account."; } break; default: if (accountNumber != -1 && accountNumber < users.Count) { title = "Success"; description = "`Pretend this sends an API request...`\nwith account " + $"`{SteamService.GetSteamName(users[accountNumber]).Replace("`", "")}` " + $"or steamid `{users[accountNumber]}`"; } else { title = "Fail"; description = "`You have multiple linked Steam accounts.`\n" + "Use command `!register n` and replace `n` with the correct account number shown below." + "```\n" + string.Join("\n", users.Select((x, index) => $"{index} - {SteamService.GetSteamName(x).Replace("`", "")}")) + "```"; } break; } } else { title = "You are already registered!"; description = "You are registered on Steam account " + $"`{SteamService.GetSteamName(player.Steam)}`"; } await ReplyAsync(embed : new LocalEmbedBuilder() .WithTitle(title) .WithDescription(description) .WithColor(Color.Honeydew) .Build()).ConfigureAwait(true); }