Beispiel #1
0
        public async Task IdAsync(Snowflake id)
        {
            string description;

            if (DUserService.GetAccounts(id).Result.Count == 0)
            {
                description = "`No Steam Accounts associated with this account.`";
            }
            else
            {
                description = string.Join("\n", DUserService.GetAccounts(id).Result.Select(x => $"`{x}`"));
            }

            await ReplyAsync(embed : new LocalEmbedBuilder()
                             .WithTitle("Steam Account Ids")
                             .WithDescription(description)
                             .WithColor(Color.Honeydew)
                             .Build()).ConfigureAwait(true);
        }
Beispiel #2
0
        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);
        }