Exemple #1
0
        public static void WriteToUserList(ArkLinkItem i)
        {
            //Load array
            ArkLinkList main = Load();
            //We have our list. See if we're on it
            bool writeNew = true;

            foreach (ArkLinkItem item in main.users)
            {
                if (item.discordId == i.discordId)
                {
                    //Just edit this, save, and exit
                    writeNew      = false;
                    item.steamIds = i.steamIds;
                }
            }
            if (writeNew)
            {
                main.users.Add(i);
            }
            //Save back
            string raw = Tools.SerializeObject(main);

            System.IO.File.WriteAllText(Program.savePath + "linked.list", raw);
        }
Exemple #2
0
        private static ArkLinkList Load()
        {
            string      path = Program.savePath + "linked.list";
            ArkLinkList main = new ArkLinkList();

            if (System.IO.File.Exists(path))
            {
                string      raw = System.IO.File.ReadAllText(path);
                ArkLinkList l   = (ArkLinkList)Tools.DeserializeObject(raw, typeof(ArkLinkList));
                main.users = l.users;
            }
            return(main);
        }
Exemple #3
0
        public static DiscordUser GetUserByArkName(string name)
        {
            //Get their id
            try
            {
                ulong id = ArkLinkList.GetDiscordUserIdBySteamName(name);

                //Create a new object.
                return(new DiscordUser("", id, DiscordUserPermissionLevel.anyone));
            } catch
            {
                return(null);
            }
        }
Exemple #4
0
        public static async Task FinishArkLink(string playerName, string steamName, DSharpPlus.Entities.DiscordMessage msg, ulong id)
        {
            //Fetch this user
            DiscordUser u = new DiscordUser("", id, DiscordUserPermissionLevel.admin);

            //We have the user and the player. Finish link
            u.isArkLinked        = true;
            u.arkLinkedUsername  = playerName;
            u.arkLinkedSteamName = steamName;
            var embed = Tools.GenerateEmbed("Ark Link", "Nice job!", "Ark link completed! You're now linked with " + u.arkLinkedUsername + "!", DiscordColor.Green);

            //Close user to save.
            u.CloseUser();
            //Write to the list of linked users.
            ArkLinkList.WriteToUserList(new ArkLinkItem(steamName.Trim(' '), id, playerName.Trim(' ')));
            await msg.ModifyAsync(embed : embed);

            //Done.
        }
Exemple #5
0
        public static ulong GetDiscordUserIdBySteamName(string query)
        {
            ArkLinkList main = Load();
            int         i    = 0;

            //Console.WriteLine("|||||||||||||||||");
            //Console.WriteLine(main.users[0].arkIds + " " + main.users[1].arkIds);
            while (i < main.users.Count)
            {
                //Console.WriteLine("");
                //Console.WriteLine(main.users[i].steamIds + "|");
                //Console.WriteLine(main.users[i].arkIds + "|");
                //Console.WriteLine(query + "|");

                //Console.WriteLine("");
                if (main.users[i].steamIds.Trim(' ') == query.Trim(' ') || main.users[i].arkIds.Trim(' ') == query.Trim(' '))
                {
                    //Console.WriteLine("RETURNING FOR " + query + " " + main.users[i].discordId.ToString());
                    return(main.users[i].discordId);
                }
                i++;
            }
            throw new Exception("Not found!");
        }