Exemplo n.º 1
0
        public async Task <PlayerStatic> ListOwnerServersInChannel(SocketCommandContext Context)
        {
            ulong serverID = 0;

            string servers = "";
            int    k       = 1;
            Dictionary <string, ulong> userControlledservers = new Dictionary <string, ulong>();

            foreach (var g in Context.Client.Guilds)
            {
                if (Context.User.Id == g.Owner.Id)
                {
                    if (PlayerStatic.DoesProfileExist(g.Id))
                    {
                        userControlledservers.Add(g.Name, g.Id);
                        servers += $"  * {g.Name} \n";
                        k++;
                    }
                }
            }

            if (userControlledservers.Count > 1)
            {
                await ReplyAsync($"You control the following servers:\n{servers} Please enter the name of the server you want to select, it does not have to be the full name.");

                var serverNameResponse = await NextMessageAsync(true, false, timeout : TimeSpan.FromMinutes(5));

                foreach (var u in userControlledservers)
                {
                    if (u.Key.ToLower().Contains(serverNameResponse.Content.ToLower()))
                    {
                        serverID = u.Value;
                        break;
                    }
                }
            }
            else
            {
                serverID = userControlledservers.Values.First();
            }



            PlayerStatic ps = PlayerStatic.Load(serverID);

            return(ps);
        }
Exemplo n.º 2
0
        public async Task <PlayerStatic> ListOwnerServers(SocketCommandContext Context)
        {
            ulong serverID = 0;

            string servers = "";
            int    k       = 1;
            Dictionary <string, ulong> userControlledservers = new Dictionary <string, ulong>();

            foreach (var g in Context.Client.Guilds)
            {
                if (Context.User.Id == g.Owner.Id)
                {
                    if (PlayerStatic.DoesProfileExist(g.Id))
                    {
                        userControlledservers.Add(g.Name, g.Id);
                        servers += $"  {k}. {g.Name} \n";
                        k++;
                    }
                }
            }

            if (userControlledservers.Count > 1)
            {
                await Context.User.SendMessageAsync($"You control the following servers:\n{servers} Please enter the number of the server you want to select.");

                var serverNameResponse = await NextMessageAsync(true, false, timeout : TimeSpan.FromMinutes(5));

                int responseInt = Convert.ToInt32(serverNameResponse.Content);
                serverID = userControlledservers.ElementAt(responseInt - 1).Value;
                await Context.User.SendMessageAsync($"You have selected: **{userControlledservers.ElementAt(responseInt-1).Key}**");
            }
            else
            {
                serverID = userControlledservers.Values.First();
            }



            PlayerStatic ps = PlayerStatic.Load(serverID);

            return(ps);
        }