예제 #1
0
        internal static Task Send(SocketMessage message)
        {
            if (!message.Author.IsBot)
            {
                if (message.Content.Contains(Program.commandChar))
                {
                    if (!UserTools.UserExists(message.Author.Id))
                    {
                        Program.userList.Add(new User(message.Author.Id));
                        FileManipulation.LoadFile(message.Author.Id.ToString());
                    }

                    try
                    {
                        string   command = message.Content.Split(Program.commandChar)[0];
                        string   rest    = message.Content.Remove(0, command.Length + 1).Trim('|');
                        string[] content = rest.Split(Program.splitChar);

                        CommandHandler.Send(message.Author.Id, command, content);
                    }
                    catch
                    {
                        message.Author.SendMessageAsync("Command is not correctly formatted, please try again or contact an administrator.");
                    }
                }
            }
            return(Task.CompletedTask);
        }
예제 #2
0
        public Group(params User[] users)
        {
            //sorts the users by their ID
            Users = users.OrderBy(u => u.ID).ToList();
            ID    = "";
            Info  = new List <Information>();

            //Generates a group ID based on the user IDs, this will always be the same if it has the same users in a group
            List <string> ids = new List <string>();

            foreach (var user in Users)
            {
                ids.Add(user.ID.ToString());
            }
            foreach (var id in ids)
            {
                ID += id.Remove(18 / ids.Count);
            }

            FileManipulation.LoadFile(ID);

            foreach (var user in Users)
            {
                string output = "You have been added to a group with the members: ";
                foreach (var User in Users)
                {
                    output += $"{Program._client.GetUser(User.ID).Username}, ";
                }
                output  = output.Trim(' ');
                output  = output.Trim(',');
                output += ".\n";

                output += $"To access the group, use the ID: {ID} after the \"§\"";

                Program._client.GetUser(user.ID).SendMessageAsync(output);
            }
        }